Last active
November 9, 2016 12:03
-
-
Save Ataurr/b862ba101d87f54a4ce21024730ecca9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function remove_subscribers() { | |
global $wpdb; | |
$args = array( 'role' => 'Subscriber' ); | |
$subscribers = get_users( $args ); | |
if ( !empty( $subscribers ) ) { | |
require_once( ABSPATH . 'wp-admin/includes/user.php' ); | |
$i = 0; | |
foreach ( $subscribers as $subscriber ) { | |
$userid = $subscriber->ID; | |
$user_info = get_userdata( $userid ); | |
$first_name = $user_info->first_name; | |
if ( $first_name == '' ) { | |
if ( wp_delete_user( $userid ) ) { | |
$i++; | |
} | |
} | |
} | |
echo $i . ' Subscribers deleted'; | |
} else { | |
echo 'No Subscribers deleted'; | |
} | |
} | |
remove_subscribers(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment