List All Roles

This snippet let’s you loop through every role registered in WordPress.

If you want to change the capabilities of a role, check out this snippet: Change Role Capabilities.

Code Snippet:

$roles = new WP_Roles();
$roles_names = $roles->get_names();
foreach ($roles_names as $role) {
    print_r($role);
}

Posted in Pure hacks