Search code examples
wordpressuser-roles

Wordpress remove_role() not working


Hi I'm trying to deleting some custom created roles with,

$wp_roles = new WP_Roles();
$wp_roles->remove_role("your_role");

Some roles deleted fine. but when I delete few otehr roles first time they seems to deleted successfully. but after next refresh they are recreating.

I'm pretty sure , this is not a something that is recreating the role if it is not exists. As I created those roles via add_role those roles are totally independent and no inside code creating those.

Thanks

I tried with "User Role Editor" plugin not worked too


Solution

  • If you have the access to phpmyadmin, try editing the database directly.

    wp_user_roles is in wp_options table.

    Each user's role/capability is in a wp_capabilities record in wp_usermeta

    There you can add/edit/delete any roles with minimum mysql knowledge.