Advertisement
cccccccc

Untitled

May 18th, 2014
233
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.50 KB | None | 0 0
  1. function remove_noroleusers() {
  2.  
  3.     global $wpdb;
  4.  
  5.     $args = array( 'meta_key' => 'wp_capabilities','meta_value' => 'a:0:{}','meta_compare' => '=') ;
  6.  
  7.     $noroleusers = get_users( $args );
  8.  
  9.     if( !empty($noroleusers) ) {
  10.  
  11.         require_once( ABSPATH.'wp-admin/includes/user.php' );
  12.  
  13.         $i = 0;
  14.  
  15.         foreach( $noroleusers as $noroleuser ) {
  16.  
  17.             // if( wp_delete_user( $noroleuser->ID ) ) { $i++; }
  18.  
  19.         }
  20.  
  21.         echo $i.' Users deleted';
  22.  
  23.     } else {
  24.  
  25.         echo 'No Users deleted';
  26.  
  27.     }
  28.  
  29. }
  30.  
  31. remove_noroleusers();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement