Import users from CSV with meta - Version 1.17.5

Version Description

  • Fixed problems importing avatar from WP User Avatar
  • Avatars using WP User Avatar can now be exported
  • Some code improvements
Download this release

Release Info

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

Code changes from version 1.17.4.4 to 1.17.5

addons/wp-user-avatar.php CHANGED
@@ -6,38 +6,63 @@ if( !is_plugin_active( 'wp-user-avatar/wp-user-avatar.php' ) ){
6
  return;
7
  }
8
 
9
- add_filter( 'acui_restricted_fields', 'acui_wpua_restricted_fields', 10, 1 );
10
- add_action( 'acui_documentation_after_plugins_activated', 'acui_wpua_documentation_after_plugins_activated' );
11
- add_action( 'post_acui_import_single_user', 'acui_wpua_post_import_single_user', 10, 3 );
12
 
13
- function acui_wpua_restricted_fields( $acui_restricted_fields ){
14
- return array_merge( $acui_restricted_fields, array( 'avatar_url' ) );
15
- }
 
16
 
17
- function acui_wpua_documentation_after_plugins_activated(){
18
- ?>
19
- <tr valign="top">
20
- <th scope="row"><?php _e( "WP Users Avatar is activated", 'import-users-from-csv-with-meta' ); ?></th>
21
- <td>
22
- <?php _e( "You can import user avatar and assign them to the users using the next format", 'import-users-from-csv-with-meta' ); ?>.
23
- <ul style="list-style:disc outside none; margin-left:2em;">
24
- <li><?php _e( "avatar_url as the column title", 'import-users-from-csv-with-meta' ); ?></li>
25
- <li><?php _e( "The value of each cell will be the url to the image in your system", 'import-users-from-csv-with-meta' ); ?></li>
26
- </ul>
27
- </td>
28
- </tr>
29
- <?php
30
- }
31
 
32
- function acui_wpua_post_import_single_user( $headers, $row, $user_id ){
33
- $pos = array_search( 'avatar_url', $headers );
 
 
 
 
 
 
 
 
 
 
 
 
34
 
35
- if( $pos === FALSE )
36
- return;
 
 
 
 
 
 
 
 
 
37
 
38
- global $blog_id, $wpdb;
39
- $avatar_url = $row[ $pos ];
 
 
 
 
 
 
 
 
40
 
41
- $avatar_id = media_sideload_image( $avatar_url, 0, 'Avatar of user ' . $user_id, 'id' );
42
- update_user_meta( $user_id, $wpdb->get_blog_prefix($blog_id).'user_avatar', "");
43
- }
6
  return;
7
  }
8
 
9
+ class ACUI_WPUA{
10
+ var $meta_key;
 
11
 
12
+ function __construct(){
13
+ global $blog_id, $wpdb;
14
+ $this->meta_key = $wpdb->get_blog_prefix( $blog_id ) . 'user_avatar';
15
+ }
16
 
17
+ function hooks(){
18
+ add_filter( 'acui_restricted_fields', array( $this, 'restricted_fields' ), 10, 1 );
19
+ add_action( 'acui_documentation_after_plugins_activated', array( $this, 'documentation_after_plugins_activated' ) );
20
+ add_action( 'post_acui_import_single_user', array( $this, 'post_import_single_user' ), 10, 3 );
21
+ add_filter( 'acui_export_columns', array( $this, 'export_columns' ), 10, 1 );
22
+ add_filter( 'acui_export_data', array( $this, 'export_data' ), 10, 3 );
23
+ }
24
+
25
+ function restricted_fields( $acui_restricted_fields ){
26
+ return array_merge( $acui_restricted_fields, array( 'avatar_url' ) );
27
+ }
 
 
 
28
 
29
+ function documentation_after_plugins_activated(){
30
+ ?>
31
+ <tr valign="top">
32
+ <th scope="row"><?php _e( "WP Users Avatar is activated", 'import-users-from-csv-with-meta' ); ?></th>
33
+ <td>
34
+ <?php _e( "You can import user avatar and assign them to the users using the next format", 'import-users-from-csv-with-meta' ); ?>.
35
+ <ul style="list-style:disc outside none; margin-left:2em;">
36
+ <li><?php _e( "avatar_url as the column title", 'import-users-from-csv-with-meta' ); ?></li>
37
+ <li><?php _e( "The value of each cell will be the url to the image in your system", 'import-users-from-csv-with-meta' ); ?></li>
38
+ </ul>
39
+ </td>
40
+ </tr>
41
+ <?php
42
+ }
43
 
44
+ function post_import_single_user( $headers, $row, $user_id ){
45
+ $pos = array_search( 'avatar_url', $headers );
46
+
47
+ if( $pos === FALSE )
48
+ return;
49
+
50
+ $avatar_url = $row[ $pos ];
51
+
52
+ $avatar_id = media_sideload_image( $avatar_url, 0, 'Avatar of user ' . $user_id, 'id' );
53
+ update_user_meta( $user_id, $this->meta_key, $avatar_id );
54
+ }
55
 
56
+ function export_columns( $row ){
57
+ $row[] = 'user_avatar';
58
+ return $row;
59
+ }
60
+
61
+ function export_data( $row, $user ){
62
+ $row[] = wp_get_attachment_url( get_user_meta( $user, $this->meta_key, true ) );
63
+ return $row;
64
+ }
65
+ }
66
 
67
+ $acui_wpua = new ACUI_WPUA();
68
+ $acui_wpua->hooks();
 
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.4.4
7
  Author: codection
8
  Author URI: https://codection.com
9
  License: GPL2
@@ -11,6 +11,7 @@ License URI: https://www.gnu.org/licenses/gpl-2.0.html
11
  Text Domain: import-users-from-csv-with-meta
12
  Domain Path: /languages
13
  */
 
14
  if ( ! defined( 'ABSPATH' ) )
15
  exit;
16
 
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.5
7
  Author: codection
8
  Author URI: https://codection.com
9
  License: GPL2
11
  Text Domain: import-users-from-csv-with-meta
12
  Domain Path: /languages
13
  */
14
+
15
  if ( ! defined( 'ABSPATH' ) )
16
  exit;
17
 
readme.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: carazo, hornero
3
  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.7
7
- Stable tag: 1.17.4.4
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -103,6 +103,11 @@ Plugin will automatically detect:
103
 
104
  == Changelog ==
105
 
 
 
 
 
 
106
  = 1.17.4.4 =
107
  * Problems importing BuddyPress Groups solved
108
 
3
  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.7.1
7
+ Stable tag: 1.17.5
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.5 =
107
+ * Fixed problems importing avatar from WP User Avatar
108
+ * Avatars using WP User Avatar can now be exported
109
+ * Some code improvements
110
+
111
  = 1.17.4.4 =
112
  * Problems importing BuddyPress Groups solved
113