UM_ADDON_bp_avatar_transfer

The Ultimate Member UM ADDON bp avatar transfer class.

Defined (1)

The class is defined in the following location(s).

/addons/bp_avatar_transfer.php  
  1. class UM_ADDON_bp_avatar_transfer { 
  2.  
  3. function __construct() { 
  4.  
  5. add_action('admin_menu', array(&$this, 'admin_menu'), 1001); 
  6.  
  7. add_action('admin_init', array(&$this, 'admin_init'), 1); 
  8.  
  9. add_action('um_admin_addon_hook', array(&$this, 'um_admin_addon_hook') ); 
  10.  
  11.  
  12. function admin_menu() { 
  13.  
  14. global $ultimatemember; 
  15. $this->addon = $ultimatemember->addons['bp_avatar_transfer']; 
  16. add_submenu_page('ultimatemember', $this->addon[0], $this->addon[0], 'manage_options', 'bp_avatar_transfer', array(&$this, 'content') ); 
  17.  
  18.  
  19. function um_admin_addon_hook( $hook ) { 
  20. global $ultimatemember; 
  21. switch( $hook ) { 
  22. case 'bp_avatar_transfer': 
  23. if ( class_exists('BuddyPress') ) { 
  24.  
  25. $path = bp_core_avatar_upload_path() . '/avatars'; 
  26.  
  27. $files = glob( $path . '/*'); 
  28. $i = 0; 
  29. foreach( $files as $key ) { 
  30. $q = (count(glob("$key/*")) === 0) ? 0 : 1; 
  31. if ( $q == 1 ) { 
  32. $photo = glob( $key . '/*'); 
  33. foreach( $photo as $file ) { 
  34. if ( strstr( $file, 'bpfull' ) ) { 
  35. $get_user_id = explode('/', $file); 
  36. array_pop($get_user_id); 
  37. $user_id = end($get_user_id); 
  38. if ( !file_exists( $ultimatemember->files->upload_basedir . $user_id . '/profile_photo.jpg' ) ) { 
  39. $ultimatemember->files->new_user( $user_id ); 
  40. copy( $file, $ultimatemember->files->upload_basedir . $user_id . '/profile_photo.jpg' ); 
  41. update_user_meta($user_id, 'profile_photo', 'profile_photo.jpg'); 
  42. $i++; 
  43.  
  44. $this->content = '<p><strong>Done. Process completed!</p>'; 
  45. $this->content .= $i . ' user(s) changed.</strong></p>'; 
  46.  
  47. break; 
  48.  
  49. function admin_init() { 
  50. if ( isset( $_REQUEST['um-addon-hook'] ) ) { 
  51. $hook = $_REQUEST['um-addon-hook']; 
  52. do_action("um_admin_addon_hook", $hook); 
  53.  
  54. function content() { 
  55.  
  56. $this->process_link = add_query_arg('um-addon-hook', 'bp_avatar_transfer'); 
  57.  
  58. ?> 
  59.  
  60. <div class="wrap"> 
  61.  
  62. <h2>Ultimate Member <sup style="font-size:15px"><?php echo ultimatemember_version; ?></sup></h2> 
  63.  
  64. <h3><?php echo $this->addon[0]; ?></h3> 
  65.  
  66. <?php if ( isset( $this->content ) ) {  
  67. echo $this->content; 
  68. } else { ?> 
  69.  
  70. <p>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.</p> 
  71. <p>Depending on your users database, this could take a few moments. To start the process, click the following button.</p> 
  72.  
  73. <p><a href="<?php echo $this->process_link; ?>" class="button button-primary">Start transferring avatars</a></p> 
  74.  
  75. <?php } ?> 
  76.  
  77. </div><div class="clear"></div> 
  78.  
  79. <?php 
  80.  
  81.