PluginProbe
Import Users & Customers with Meta | WP Ultimate CSV Importer Add-on / 1.4.2
Import Users & Customers with Meta | WP Ultimate CSV Importer Add-on v1.4.2
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 +22 -9 1.21.4.2 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,9 +64,13 @@
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' ) {
72 + $send_password = $data_array['user_pass'] ;
70 73 if ( empty( $data_array['user_pass'] ) ) {
71 74 $data_array['user_pass'] = wp_generate_password( 12, false );
72 75 $additional_meta_info = array(
73 76 'user_login' => $data_array['user_login'],
@@ -76,9 +79,12 @@
76 79 'role' => $data_array['role']
77 80 );
78 81 $data_array['smack_uci_import'] = $additional_meta_info;
79 82 }
80 - else{
83 + else{
84 + if (strlen($data_array['user_pass'])!== 34 && $data_array['user_pass'][0]!=='$'){
85 + $data_array['user_pass']=wp_hash_password($data_array['user_pass']);
86 + }
81 87 $additional_meta_info = array(
82 88 'user_login' => $data_array['user_login'],
83 89 'user_pass' => $data_array['user_pass'],
84 90 'user_email' => $data_array['user_email'],
@@ -86,8 +92,12 @@
86 92 );
87 93 $data_array['smack_uci_import'] = $additional_meta_info;
88 94 }
89 95 $retID = wp_insert_user($data_array);
96 + update_user_meta($retID, 'sendPassword', $send_password);
97 + if ( !is_wp_error($retID) && !empty( $data_array['user_pass'] ) ) {
98 + $wpdb->get_results("UPDATE {$wpdb->prefix}users SET user_pass = '{$data_array['user_pass']}' WHERE ID = $retID");
99 + }
90 100 $mode_of_affect = 'Inserted';
91 101
92 102 if ( is_wp_error( $retID ) ) {
93 103 $core_instance->detailed_log[$line_number]['Message'] = "Skipped, Due to duplicate User found with same email!.";
@@ -152,14 +162,17 @@
152 162
153 163 if ( ! empty ( $metaData ) ) {
154 164 foreach ( $metaData as $meta_key => $meta_value ) {
155 165 update_user_meta( $retID, $meta_key, $meta_value );
166 +
167 + //filter for modifying user metadata after import
168 + apply_filters('smack_csv_modify_metadata_filter', $retID, $meta_key, $meta_value);
156 169 }
157 170 }
158 171 $core_instance->detailed_log[$line_number]['Email'] = $data_array['user_email'];
159 172 $core_instance->detailed_log[$line_number]['Role'] = $data_array['role'];
160 173 $ucisettings = get_option('sm_uci_pro_settings');
161 - if($ucisettings['send_user_password'] == "true") {
174 + if(isset($ucisettings['send_user_password']) && $ucisettings['send_user_password'] == "true") {
162 175 $send_user_password = new SendPassword;
163 176 $send_user_password->send_login_credentials_to_users();
164 177 }
165 178 $returnArr['ID'] = $retID;