Skip to content

Instantly share code, notes, and snippets.

@Ataurr
Last active November 9, 2016 12:03
Show Gist options
  • Save Ataurr/b862ba101d87f54a4ce21024730ecca9 to your computer and use it in GitHub Desktop.
Save Ataurr/b862ba101d87f54a4ce21024730ecca9 to your computer and use it in GitHub Desktop.
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