Title: What WordPress/PHP code can delete all subscribers?
Last modified: February 16, 2021

---

# What WordPress/PHP code can delete all subscribers?

 *  Resolved [mplusplus](https://wordpress.org/support/users/mplusplus/)
 * (@mplusplus)
 * [5 years, 3 months ago](https://wordpress.org/support/topic/what-wordpress-php-code-can-delete-all-subscribers/)
 * Hi there
 * What WordPress/PHP code can delete all subscribers?
 * Thanks.

Viewing 4 replies - 1 through 4 (of 4 total)

 *  [corrinarusso](https://wordpress.org/support/users/corrinarusso/)
 * (@corrinarusso)
 * [5 years, 3 months ago](https://wordpress.org/support/topic/what-wordpress-php-code-can-delete-all-subscribers/#post-14059891)
 * [https://www.wpbeginner.com/plugins/how-to-bulk-delete-wordpress-users-with-specific-roles/](https://www.wpbeginner.com/plugins/how-to-bulk-delete-wordpress-users-with-specific-roles/)
 *  Thread Starter [mplusplus](https://wordpress.org/support/users/mplusplus/)
 * (@mplusplus)
 * [5 years, 3 months ago](https://wordpress.org/support/topic/what-wordpress-php-code-can-delete-all-subscribers/#post-14059916)
 * Hi [@corrinarusso](https://wordpress.org/support/users/corrinarusso/)
 * The link does not have any PHP/WordPress code to delete all subscribers. It has
   plugins and the manual way, and none of them work for me.
 * Thanks.
 *  [corrinarusso](https://wordpress.org/support/users/corrinarusso/)
 * (@corrinarusso)
 * [5 years, 3 months ago](https://wordpress.org/support/topic/what-wordpress-php-code-can-delete-all-subscribers/#post-14060004)
 * The safest way to do this is using the cli, like this :
    `wp user delete $(wp
   user list --role=subscriber --field=ID) --reassign=1`
 * [https://developer.wordpress.org/cli/commands/user/delete/](https://developer.wordpress.org/cli/commands/user/delete/)
 * Make sure you backup first, but you could use some SQL like this :
    `DELETE wu
   FROM`wp_users` wu INNER JOIN wp_usermeta ON wu.ID = wp_usermeta.user_id WHERE
   meta_key = ‘wp_capabilities’ AND meta_value LIKE ‘%administrator%’`
 * Make sure you run a select before a delete just to be sure you have the data 
   you want.
 *  Thread Starter [mplusplus](https://wordpress.org/support/users/mplusplus/)
 * (@mplusplus)
 * [5 years, 1 month ago](https://wordpress.org/support/topic/what-wordpress-php-code-can-delete-all-subscribers/#post-14300411)
 * I got this working using [https://wordpress.org/support/topic/using-wordpress-php-code-how-to-bulk-delete-100-subscribers-at-a-time/#post-14201859](https://wordpress.org/support/topic/using-wordpress-php-code-how-to-bulk-delete-100-subscribers-at-a-time/#post-14201859)
 * Thanks.

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘What WordPress/PHP code can delete all subscribers?’ is closed to new
replies.

 * In: [Developing with WordPress](https://wordpress.org/support/forum/wp-advanced/)
 * 4 replies
 * 2 participants
 * Last reply from: [mplusplus](https://wordpress.org/support/users/mplusplus/)
 * Last activity: [5 years, 1 month ago](https://wordpress.org/support/topic/what-wordpress-php-code-can-delete-all-subscribers/#post-14300411)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
