apply_filters( ‘editable_roles’, array[] $all_roles )

Filters the list of editable roles.


Array of arrays containing role information.

More Information

editable_roles is a filter applied by the function get_editable_roles() to the list of roles that one user can assign to others (a user must have the edit_users capability to change another user’s role). This list is displayed in the bulk operations (if the user has the list_users and promote_users) of the Users Screen, and on the profile screen.


$editable_roles = apply_filters( 'editable_roles', $all_roles );



User Contributed Notes

  1. Skip to note 3 content

    Example migrated from Codex:

    Filter out roles with levels higher than the current user’s:

    add_filter('editable_roles', 'remove_higher_levels');
    function remove_higher_levels($all_roles) {
        $user = wp_get_current_user();
        $next_level = 'level_' . ($user->user_level + 1);
        foreach ( $all_roles as $name => $role ) {
            if (isset($role['capabilities'][$next_level])) {
        return $all_roles;
  2. Skip to note 4 content

    Example migrated from Codex:

    Add a “No role” option that sets users’ roles to nothing on pages other than the user profile screen (where it already exists):

    add_filter('editable_roles', 'add_empty_editable_role');
    function add_empty_editable_role($all_roles) {
        $screen = get_current_screen();
        if (! (isset($all_roles['']) || 'user-edit' == $screen->id)) {
            $all_roles[''] = array(
                'name' => __('— No role for this site —'),
                'capabilities' => array(),
        return $all_roles;

You must log in before being able to contribute a note or feedback.