Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Sep 11th, 2013  |  syntax: None  |  size: 0.97 KB  |  views: 42  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. //for /mu-plugins/
  2.  
  3. add_action('network_admin_menu', 'ds_emails_all_add_menu');
  4.  
  5. function ds_emails_all_add_menu()
  6. {
  7.                 add_submenu_page('settings.php', 'Email All', 'Email All', 'manage_network', 'email_all', 'ds_emails_all_page');
  8. }
  9.  
  10.  
  11. function ds_emails_all_page()
  12. {
  13. if( is_super_admin() == false ) {
  14.         wp_die( __('You do not have permission to access this page.') );
  15. }
  16. ?>
  17. <div class='wrap'>
  18. <h2>Email All</h2>
  19. <p>Following is a list of email addresses that are administrators of one or more blogs on this WPMU installation.</p>
  20. <pre>
  21. <?php
  22. global $wpdb;
  23.  
  24. $query = "SELECT DISTINCT (u.user_email) FROM $wpdb->usermeta m INNER JOIN $wpdb->users u on m.user_id=u.id WHERE meta_key like 'wp_%_user_level' and meta_value='10' ORDER BY 1";
  25.  
  26. //$query = "SELECT DISTINCT user_email FROM $wpdb->users ORDER BY user_email ASC"; //all users
  27.  
  28. $emails = $wpdb->get_results($query);
  29.  
  30. foreach ($emails as $e) {
  31.         echo "$e->user_email, \n";
  32. }
  33. ?>
  34. </pre>
  35. </div>
  36. <?php
  37. }
  38. ?>
clone this paste RAW Paste Data