get_editable_roles() WP 1.0
Fetch a filtered list of user roles that the current user is allowed to edit.
Simple function whose main purpose is to allow filtering of the list of roles in the $wp_roles object so that plugins can remove inappropriate ones depending on the situation or user making edits. Specifically because without filtering anyone with the edit_users capability can edit others to be administrators, even if they are only editors or authors. This filter allows admins to delegate user management.
Works based on: wp_roles()
Basis of: wp_dropdown_roles()
1 time = 0.000358s = fast | 50000 times = 8.56s = fast | PHP 7.0.32, WP 5.1
Hooks from the function
Return
Array[]. Array of arrays containing role information.
Usage
get_editable_roles();
Changelog
Since 2.8.0 | Introduced. |
Code of get_editable_roles() get editable roles WP 5.6
function get_editable_roles() {
$all_roles = wp_roles()->roles;
/**
* Filters the list of editable roles.
*
* @since 2.8.0
*
* @param array[] $all_roles Array of arrays containing role information.
*/
$editable_roles = apply_filters( 'editable_roles', $all_roles );
return $editable_roles;
}Related Functions
From tag: Roles capabilities
More from category: Other
- auth_redirect()
- count_many_users_posts()
- count_user_posts()
- count_users()
- email_exists()
- get_author_posts_url()
- get_current_user_id()
- get_the_author()
- get_the_author_link()