| 1 |
<?php |
| 2 |
/****************************************************************************************** |
| 3 |
* Copyright (C) Smackcoders. - All Rights Reserved under Smackcoders Proprietary License |
| 4 |
* Unauthorized copying of this file, via any medium is strictly prohibited |
| 5 |
* Proprietary and confidential |
| 6 |
* You can contact Smackcoders at email address info@smackcoders.com. |
| 7 |
*******************************************************************************************/ |
| 8 |
|
| 9 |
namespace Smackcoders\SMUSERS; |
| 10 |
|
| 11 |
if ( ! defined( 'ABSPATH' ) ) |
| 12 |
exit; // Exit if accessed directly |
| 13 |
|
| 14 |
class MultiroleImport extends UsersImport { |
| 15 |
|
| 16 |
private static $multirole_instance = null; |
| 17 |
|
| 18 |
public static function getInstance() { |
| 19 |
|
| 20 |
if (MultiroleImport::$multirole_instance == null) { |
| 21 |
MultiroleImport::$multirole_instance = new MultiroleImport; |
| 22 |
return MultiroleImport::$multirole_instance; |
| 23 |
} |
| 24 |
return MultiroleImport::$multirole_instance; |
| 25 |
} |
| 26 |
|
| 27 |
function set_multirole_values($header_array ,$value_array , $map, $post_id , $type){ |
| 28 |
$post_values = []; |
| 29 |
$helpers_instance = ImportHelpers::getInstance(); |
| 30 |
$post_values = $helpers_instance->get_header_values($map , $header_array , $value_array); |
| 31 |
|
| 32 |
$this->multirole_import_function($post_values, $post_id); |
| 33 |
|
| 34 |
} |
| 35 |
|
| 36 |
public function multirole_import_function($data_array, $uID){ |
| 37 |
global $wpdb; |
| 38 |
if(isset($data_array['multi_user_role'])){ |
| 39 |
$roles = explode('|', $data_array['multi_user_role']); |
| 40 |
foreach ($roles as $key => $value) { |
| 41 |
$members_role[$value] = 1; |
| 42 |
} |
| 43 |
update_user_meta($uID, $wpdb->prefix.'capabilities', $members_role); |
| 44 |
} |
| 45 |
} |
| 46 |
} |
| 47 |
global $member_class; |
| 48 |
$member_class = new MultiroleImport(); |