diff --git a/addons/bp_avatar_transfer.php b/addons/bp_avatar_transfer.php new file mode 100644 index 00000000..d195545a --- /dev/null +++ b/addons/bp_avatar_transfer.php @@ -0,0 +1,108 @@ +addon = $ultimatemember->addons['bp_avatar_transfer']; + add_submenu_page('ultimatemember', $this->addon[0], $this->addon[0], 'manage_options', 'bp_avatar_transfer', array(&$this, 'content') ); + + } + + /*** + *** @Runs a custom hook + ***/ + function um_admin_addon_hook( $hook ) { + global $ultimatemember; + switch( $hook ) { + case 'bp_avatar_transfer': + if ( class_exists('BuddyPress') ) { + + $path = bp_core_avatar_upload_path() . '/avatars'; + + $files = glob( $path . '/*'); + $i = 0; + foreach( $files as $key ) { + $q = (count(glob("$key/*")) === 0) ? 0 : 1; + if ( $q == 1 ) { + $photo = glob( $key . '/*'); + foreach( $photo as $file ) { + if ( strstr( $file, 'bpfull' ) ) { + $get_user_id = explode('/', $file); + array_pop($get_user_id); + $user_id = end($get_user_id); + if ( !file_exists( $ultimatemember->files->upload_basedir . $user_id . '/profile_photo.jpg' ) ) { + $ultimatemember->files->new_user( $user_id ); + copy( $file, $ultimatemember->files->upload_basedir . $user_id . '/profile_photo.jpg' ); + update_user_meta($user_id, 'profile_photo', 'profile_photo.jpg'); + $i++; + } + } + } + } + } + + $this->content = '

Done. Process completed!

'; + $this->content .= $i . ' user(s) changed.

'; + + } + break; + } + } + + /*** + *** @Change admin content + ***/ + function admin_init() { + if ( isset( $_REQUEST['um-addon-hook'] ) ) { + $hook = $_REQUEST['um-addon-hook']; + do_action("um_admin_addon_hook", $hook); + } + } + + function content() { + + $this->process_link = add_query_arg('um-addon-hook','bp_avatar_transfer'); + + ?> + +
+ +

Ultimate Member

+ +

addon[0]; ?>

+ + content ) ) { + echo $this->content; + } else { ?> + +

This tool allows you to move all custom user photos/avatars from BuddyPress to Ultimate Member platform. This can help you If you are switching from BuddyPress.

+

Depending on your users database, this could take a few moments. To start the process, click the following button.

+ +

Start transferring avatars

+ + + +
+ + send_checkin(true); exit( wp_redirect( remove_query_arg('um_adm_action') ) ); diff --git a/admin/core/um-admin-dashboard.php b/admin/core/um-admin-dashboard.php index b3f90f9e..58347b35 100644 --- a/admin/core/um-admin-dashboard.php +++ b/admin/core/um-admin-dashboard.php @@ -154,7 +154,7 @@ class UM_Admin_Dashboard { function admin_page() { $page = $_REQUEST['page']; - if ( $page == 'ultimatemember' ) { + if ( $page == 'ultimatemember' && !isset($_REQUEST['um-addon']) ) { ?> diff --git a/admin/core/um-admin-metabox.php b/admin/core/um-admin-metabox.php index 1b1fae63..0c26b61d 100644 --- a/admin/core/um-admin-metabox.php +++ b/admin/core/um-admin-metabox.php @@ -428,15 +428,15 @@ class UM_Admin_Metabox { } // needed on forms only - if ( isset( $screen->id ) && strstr( $screen->id, 'um_form' ) ) { + if ( !isset( $this->is_loaded ) && isset( $screen->id ) && strstr( $screen->id, 'um_form' ) ) { $settings['textarea_rows'] = 8; - echo '