How to remove WordPress user roles
If you found there are some spam user roles in your site then you may wish to remove them. Here is the simple way of how to remove WordPress user roles. No need to install any plugin.
Step 1: First you need to know the roles name. Create a PHP file (for example remove-wordpress-user-roles.php) with the following codes and upload them to the root of your site.
<!--?php
define( 'WP_USE_THEMES', false );
require( './wp-load.php' );
//Step 1, show all user roles in your site
$wp_roles = new WP_Roles();
$names = $wp_roles--->get_names();
print_r($names);
Step 2: Open the file in your browser, if you use Firefox then please click CTRL + U, what you see will such as the following, copy the user roles name( with a red underline as the following) you want to remove.
Step 3: Change the PHP file to the following codes and upload to your site root again, open in your browser then the roles “shop_manager”, “shop_accountant”, “shop_worker” and “shop_vendor” will be removed.
<!--?php
define( 'WP_USE_THEMES', false );
require( './wp-load.php' );
//Step 2, remove your role
$wp_roles->remove_role("shop_manager");
$wp_roles->remove_role("shop_accountant");
$wp_roles->remove_role("shop_worker");
$wp_roles->remove_role("shop_vendor");
Once done, just delete the file remove-wordpress-user-roles.php from your server
Post a Comment