2

I installed BuddyPress which created additional user roles but even after deleting BuddyPress those roles are still there. How can I delete these roles? I have tried the remove_role() command but it did not work.

2 Answers 2

4
$wp_roles = new WP_Roles(); // create new role object
$wp_roles->remove_role('name_of_role');

If you need to check the name_of_role use

$wp_roles->get_names();

you will get an array of name_of_role => Nicename of Role

Alternatively, you could use the global object $wp_roles

global $wp_roles;
1
  • Where should I put this code?
    – shenkwen
    Jul 9, 2021 at 21:46
2

A nice, user-friendly way of deleting your custom roles is using the Members plugin.

Once you install and activate it, go to Users > Roles and here you can delete an custom roles that you do not need, which you can see here:

enter image description here

Once you've remove the unwanted roles, you can simply delete the Members plugin.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.