Created
June 13, 2023 14:07
-
-
Save coulterpeterson/9b28e7d9fdc8ad409846428b225a1413 to your computer and use it in GitHub Desktop.
Delete All Subscribers in WordPress Site
This file contains hidden or 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 delete_all_subscribers() { | |
require_once(dirname( ABSPATH ) . '/public_html/wp-admin/includes/user.php'); | |
$args = array( | |
'role' => 'subscriber', | |
); | |
$users = get_users( $args ); | |
foreach ( $users as $user ) { | |
wp_delete_user($user->id); | |
} | |
} | |
delete_all_subscribers(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment