UM_ADDON_gravatar_transfer

The Ultimate Member UM ADDON gravatar transfer class.

Defined (1)

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

/addons/gravatar_transfer.php  
  1. class UM_ADDON_gravatar_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 gravatar_hash() { 
  13. global $wpdb; 
  14. $wpdb->query('DELETE FROM '.$wpdb->usermeta.' WHERE meta_key = "synced_gravatar_hashed_id" '); 
  15.  
  16. $wpdb->query('INSERT INTO '.$wpdb->usermeta.'(user_id, meta_key, meta_value)  
  17. SELECT ID, "synced_gravatar_hashed_id", MD5( LOWER( TRIM(user_email) ) ) FROM '.$wpdb->users.' ');  
  18.  
  19. return true; 
  20.  
  21. function admin_menu() { 
  22.  
  23. global $ultimatemember; 
  24. $this->addon = $ultimatemember->addons['gravatar_transfer']; 
  25. add_submenu_page('ultimatemember', $this->addon[0], $this->addon[0], 'manage_options', 'gravatar_transfer', array(&$this, 'content') ); 
  26.  
  27.  
  28. function um_admin_addon_hook( $hook ) { 
  29. global $ultimatemember; 
  30. switch( $hook ) { 
  31. case 'gravatar_transfer': 
  32. if( $this->gravatar_hash() ) { 
  33. $this->content = '<p><strong>Done. Process completed!</p>'; 
  34. $result = count_users(); 
  35. $this->content .= $result['total_users'] . ' user(s) changed.</strong></p>'; 
  36. break; 
  37.  
  38. function admin_init() { 
  39. if ( isset( $_REQUEST['um-addon-hook'] ) ) { 
  40. $hook = $_REQUEST['um-addon-hook']; 
  41. do_action("um_admin_addon_hook", $hook); 
  42.  
  43. function content() { 
  44.  
  45. $this->process_link = add_query_arg('um-addon-hook', 'gravatar_transfer'); 
  46.  
  47. ?> 
  48.  
  49. <div class="wrap"> 
  50.  
  51. <h2>Ultimate Member <sup style="font-size:15px"><?php echo ultimatemember_version; ?></sup></h2> 
  52.  
  53. <h3><?php echo $this->addon[0]; ?></h3> 
  54.  
  55. <?php if ( isset( $this->content ) ) {  
  56. echo $this->content; 
  57. } else { ?> 
  58.  
  59. <p>This tool allows you to add gravatars to Ultimate Member users. This can help you to link gravatar photos to user accounts with their email address.</p> 
  60. <p>Depending on your users database, this could take a few moments. To start the process, click the following button.</p> 
  61.  
  62. <p><a href="<?php echo $this->process_link; ?>" class="button button-primary">Start adding gravatars</a></p> 
  63.  
  64. <?php } ?> 
  65.  
  66. </div><div class="clear"></div> 
  67.  
  68. <?php 
  69.