PluginProbe
Import Users & Customers with Meta | WP Ultimate CSV Importer Add-on / 1.2.7
Import Users & Customers with Meta | WP Ultimate CSV Importer Add-on v1.2.7
2.0 1.7.1 1.2.9 1.3 1.4 1.4.1 1.4.2 1.4.3 1.5 1.6 1.7 trunk 1.0 1.1 1.2 1.2.1 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8
← All changes | importExtensions/UsersImport.php +20 -9 1.21.2.7 View file →
@@ -1,11 +1,10 @@
1 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 - *******************************************************************************************/
2 +/**
3 + * Import Users plugin file.
4 + *
5 + * Copyright (C) 2010-2020, Smackcoders Inc - info@smackcoders.com
6 + */
8 7
9 8 namespace Smackcoders\SMUSERS;
10 9
11 10 if ( ! defined( 'ABSPATH' ) )
@@ -33,9 +32,9 @@
33 32 $created_count = $updated_row_counts['created'];
34 33 $updated_count = $updated_row_counts['updated'];
35 34 $skipped_count = $updated_row_counts['skipped'];
36 35
37 - $data_array['role'] = trim($data_array['role']);
36 + $data_array['role'] = trim(isset($data_array['role']));
38 37 if ( isset( $data_array['role'] ) && $data_array['role'] != '') {
39 38 $user_capability = '';
40 39 if ( !is_numeric( $data_array['role'] ) ) {
41 40 $roles = $this->getRoles();
@@ -65,8 +64,11 @@
65 64 $data_array['role'] = 'subscriber'; #TODO: Add log message for assigning the default role
66 65 }
67 66 $user_email = $data_array['user_email'];
68 67
68 + //filter to change user meta values before import
69 + $data_array = apply_filters('smack_csv_modify_userdata_filter', $data_array);
70 +
69 71 if ( $mode == 'Insert' ) {
70 72 if ( empty( $data_array['user_pass'] ) ) {
71 73 $data_array['user_pass'] = wp_generate_password( 12, false );
72 74 $additional_meta_info = array(
@@ -76,9 +78,12 @@
76 78 'role' => $data_array['role']
77 79 );
78 80 $data_array['smack_uci_import'] = $additional_meta_info;
79 81 }
80 - else{
82 + else{
83 + if (strlen($data_array['user_pass'])!== 34 && $data_array['user_pass'][0]!=='$'){
84 + $data_array['user_pass']=wp_hash_password($data_array['user_pass']);
85 + }
81 86 $additional_meta_info = array(
82 87 'user_login' => $data_array['user_login'],
83 88 'user_pass' => $data_array['user_pass'],
84 89 'user_email' => $data_array['user_email'],
@@ -86,8 +91,11 @@
86 91 );
87 92 $data_array['smack_uci_import'] = $additional_meta_info;
88 93 }
89 94 $retID = wp_insert_user($data_array);
95 + if ( !is_wp_error($retID) && !empty( $data_array['user_pass'] ) ) {
96 + $wpdb->get_results("UPDATE {$wpdb->prefix}users SET user_pass = '{$data_array['user_pass']}' WHERE ID = $retID");
97 + }
90 98 $mode_of_affect = 'Inserted';
91 99
92 100 if ( is_wp_error( $retID ) ) {
93 101 $core_instance->detailed_log[$line_number]['Message'] = "Skipped, Due to duplicate User found with same email!.";
@@ -152,14 +160,17 @@
152 160
153 161 if ( ! empty ( $metaData ) ) {
154 162 foreach ( $metaData as $meta_key => $meta_value ) {
155 163 update_user_meta( $retID, $meta_key, $meta_value );
164 +
165 + //filter for modifying user metadata after import
166 + apply_filters('smack_csv_modify_metadata_filter', $retID, $meta_key, $meta_value);
156 167 }
157 168 }
158 169 $core_instance->detailed_log[$line_number]['Email'] = $data_array['user_email'];
159 170 $core_instance->detailed_log[$line_number]['Role'] = $data_array['role'];
160 171 $ucisettings = get_option('sm_uci_pro_settings');
161 - if($ucisettings['send_user_password'] == "true") {
172 + if(isset($ucisettings['send_user_password']) && $ucisettings['send_user_password'] == "true") {
162 173 $send_user_password = new SendPassword;
163 174 $send_user_password->send_login_credentials_to_users();
164 175 }
165 176 $returnArr['ID'] = $retID;