Import users from CSV with meta - Version 1.17.2.1

Version Description

  • Addon included for WP User Manager - WPUM Groups
  • BuddyPress addon improved
Download this release

Release Info

Developer carazo
Plugin Icon 128x128 Import users from CSV with meta
Version 1.17.2.1
Comparing to
See all releases

Code changes from version 1.17.2 to 1.17.2.1

addons/buddypress.php CHANGED
@@ -66,6 +66,20 @@ class ACUI_Buddypress{
66
  }
67
  }
68
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
69
  function get_groups( $user_id ){
70
  if( !class_exists( "BP_Groups_Member" ) ){
71
  require_once( WP_PLUGIN_DIR . "/buddypress/bp-groups/classes/class-bp-groups-member.php" );
@@ -89,11 +103,12 @@ class ACUI_Buddypress{
89
  <th scope="row"><label><?php _e( 'BuddyPress/BuddyBoss users', 'import-users-from-csv-with-meta' ); ?></label></th>
90
  <td><?php _e( 'You can insert any profile from BuddyPress using his name as header. Plugin will check, before import, which fields are defined in BuddyPress and will assign it in the update. You can use this fields:', 'import-users-from-csv-with-meta' ); ?>
91
  <ul style="list-style:disc outside none;margin-left:2em;">
92
- <?php foreach ( $this->get_fields() as $buddypress_field ): ?><li><?php echo $buddypress_field; ?></li><?php endforeach; ?>
 
 
 
 
93
  </ul>
94
- <?php _e( 'Remember that all date fields have to be imported using a format like this: 2016-01-01 00:00:00', 'import-users-from-csv-with-meta' ); ?>
95
-
96
- <p class="description"><strong>(<?php _e( 'Only for', 'import-users-from-csv-with-meta' ); ?> <a href="https://wordpress.org/plugins/buddypress/">BuddyPress</a> <?php _e( 'users', 'import-users-from-csv-with-meta' ); ?></strong>.)</p>
97
  </td>
98
  </tr>
99
  </tbody>
@@ -179,6 +194,11 @@ class ACUI_Buddypress{
179
  xprofile_set_field_data( $field, $user_id, date( 'Y-m-d H:i:s', $datebox ) );
180
  unset( $datebox );
181
  break;
 
 
 
 
 
182
  default:
183
  xprofile_set_field_data( $field, $user_id, $row[$pos] );
184
  }
66
  }
67
  }
68
 
69
+ function get_type_import_help( $type ){
70
+ switch( $type ){
71
+ case 'datebox':
72
+ $help = __( sprintf( 'Format should be like this: %s-01-01 00:00:00', date( 'Y' ) ), 'import-users-from-csv-with-meta' );
73
+ break;
74
+
75
+ case 'checkbox':
76
+ $help = __( 'If you use more than one value, please use commas to separate each item', 'import-users-from-csv-with-meta' );
77
+ break;
78
+ }
79
+
80
+ return empty( $help ) ? '' : " <em>($help)</em>";
81
+ }
82
+
83
  function get_groups( $user_id ){
84
  if( !class_exists( "BP_Groups_Member" ) ){
85
  require_once( WP_PLUGIN_DIR . "/buddypress/bp-groups/classes/class-bp-groups-member.php" );
103
  <th scope="row"><label><?php _e( 'BuddyPress/BuddyBoss users', 'import-users-from-csv-with-meta' ); ?></label></th>
104
  <td><?php _e( 'You can insert any profile from BuddyPress using his name as header. Plugin will check, before import, which fields are defined in BuddyPress and will assign it in the update. You can use this fields:', 'import-users-from-csv-with-meta' ); ?>
105
  <ul style="list-style:disc outside none;margin-left:2em;">
106
+ <?php foreach ( $this->get_fields() as $buddypress_field ):
107
+ $type = $this->get_field_type( $buddypress_field );
108
+ ?>
109
+ <li><?php echo $buddypress_field; ?> - <?php echo $type . $this->get_type_import_help( $type ); ?></li>
110
+ <?php endforeach; ?>
111
  </ul>
 
 
 
112
  </td>
113
  </tr>
114
  </tbody>
194
  xprofile_set_field_data( $field, $user_id, date( 'Y-m-d H:i:s', $datebox ) );
195
  unset( $datebox );
196
  break;
197
+
198
+ case 'checkbox':
199
+ xprofile_set_field_data( $field, $user_id, explode( ',', $row[ $pos ] ) );
200
+ break;
201
+
202
  default:
203
  xprofile_set_field_data( $field, $user_id, $row[$pos] );
204
  }
addons/wpml.php ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) exit;
4
+
5
+ if( !is_plugin_active( 'sitepress-multilingual-cms/sitepress.php' ) ){
6
+ return;
7
+ }
8
+
9
+ class ACUI_WPML{
10
+ function __construct(){
11
+ }
12
+
13
+ function hooks(){
14
+ add_filter( 'acui_import_email_body_source', array( $this, 'translated_body' ), 10, 5 );
15
+ add_filter( 'acui_import_email_subject_source', array( $this, 'translated_subject' ), 10, 5 );
16
+ }
17
+
18
+ function get_translated_template( $template_id, $locale ){
19
+ $translated_template_id = apply_filters( 'wpml_object_id', $template_id, 'acui_email_template', false, $locale );
20
+
21
+ if( empty( $translated_template_id ) )
22
+ return false;
23
+
24
+ return get_post( $translated_template_id );
25
+ }
26
+
27
+ function translated_body( $body, $headers, $data, $created, $user_id ){
28
+ $locale = ACUI_Helper::get_value_from_row( 'locale', $headers, $data );
29
+
30
+ if( empty( $locale ) )
31
+ return $body;
32
+
33
+ $template_id = get_option( "acui_mail_template_id" );
34
+ $locale = substr( $locale, 0, 2 );
35
+
36
+ $translated_template = $this->get_translated_template( $template_id, $locale );
37
+
38
+ if( empty( $translated_template ) )
39
+ return $body;
40
+
41
+ return $translated_template->post_content;
42
+ }
43
+
44
+ function translated_subject( $body, $headers, $data, $created, $user_id ){
45
+ $locale = ACUI_Helper::get_value_from_row( 'locale', $headers, $data, $user_id );
46
+
47
+ if( empty( $locale ) )
48
+ return $body;
49
+
50
+ $template_id = get_option( "acui_mail_template_id" );
51
+ $locale = substr( $locale, 0, 2 );
52
+
53
+ $translated_template = $this->get_translated_template( $template_id, $locale );
54
+
55
+ if( empty( $translated_template ) )
56
+ return $body;
57
+
58
+ return $translated_template->post_title;
59
+ }
60
+
61
+
62
+ }
63
+
64
+ $acui_wpml = new ACUI_WPML();
65
+ $acui_wpml->hooks();
classes/helper.php CHANGED
@@ -293,11 +293,12 @@ class ACUI_Helper{
293
  <?php
294
  }
295
 
296
- static function get_value_from_row( $key, $headers, $row ){
297
  $pos = array_search( $key, $headers );
298
 
299
- if( $pos === false )
300
- return false;
 
301
 
302
  return $row[ $pos ];
303
  }
293
  <?php
294
  }
295
 
296
+ static function get_value_from_row( $key, $headers, $row, $user_id = 0 ){
297
  $pos = array_search( $key, $headers );
298
 
299
+ if( $pos === false ){
300
+ return ( $user_id == 0 ) ? false : get_user_meta( $user_id, $key, true );
301
+ }
302
 
303
  return $row[ $pos ];
304
  }
classes/import.php CHANGED
@@ -596,7 +596,7 @@ class ACUI_Import{
596
 
597
  $acui_helper->print_row_imported( $row, $data, $errors );
598
 
599
- do_action('post_acui_import_single_user', $headers, $data, $user_id, $role, $positions, $form_data );
600
 
601
  $mail_for_this_user = false;
602
  if( $is_cron ){
596
 
597
  $acui_helper->print_row_imported( $row, $data, $errors );
598
 
599
+ do_action('post_acui_import_single_user', $headers, $data, $user_id, $role, $positions, $form_data, $is_frontend, $is_cron );
600
 
601
  $mail_for_this_user = false;
602
  if( $is_cron ){
import-users-from-csv-with-meta.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: Import and export users and customers
4
  Plugin URI: https://www.codection.com
5
  Description: Using this plugin you will be able to import and export users or customers choosing many options and interacting with lots of other plugins
6
- Version: 1.17.2
7
  Author: codection
8
  Author URI: https://codection.com
9
  License: GPL2
3
  Plugin Name: Import and export users and customers
4
  Plugin URI: https://www.codection.com
5
  Description: Using this plugin you will be able to import and export users or customers choosing many options and interacting with lots of other plugins
6
+ Version: 1.17.2.1
7
  Author: codection
8
  Author URI: https://codection.com
9
  License: GPL2
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: https://codection.com/go/donate-import-users-from-csv-with-meta/
4
  Tags: csv, import, importer, meta data, meta, user, users, user meta, editor, profile, custom, fields, delimiter, update, insert
5
  Requires at least: 3.4
6
  Tested up to: 5.6
7
- Stable tag: 1.17.2
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -103,6 +103,10 @@ Plugin will automatically detect:
103
 
104
  == Changelog ==
105
 
 
 
 
 
106
  = 1.17.2 =
107
  * New addon included for WPML
108
  * Email templates are being sent translated if you use the "locale" column in your CSV, so every user will receive the email translated in their own langauge
4
  Tags: csv, import, importer, meta data, meta, user, users, user meta, editor, profile, custom, fields, delimiter, update, insert
5
  Requires at least: 3.4
6
  Tested up to: 5.6
7
+ Stable tag: 1.17.2.1
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
103
 
104
  == Changelog ==
105
 
106
+ = 1.17.2.1 =
107
+ * Addon included for WP User Manager - WPUM Groups
108
+ * BuddyPress addon improved
109
+
110
  = 1.17.2 =
111
  * New addon included for WPML
112
  * Email templates are being sent translated if you use the "locale" column in your CSV, so every user will receive the email translated in their own langauge