- This topic has 3 replies, 2 voices, and was last updated 3 years, 2 months ago by .
Viewing 4 posts - 1 through 4 (of 4 total)
Viewing 4 posts - 1 through 4 (of 4 total)
- You must be logged in to reply to this topic.
There is a bug in the Roles menu when editing a user. Instead of being alphabetical, it lists the role last edited at the top. This means that anytime a role is edited, it lists that one at the top. This makes the list of roles hard to read as they are in no order.
Hi Jason,
The role dropdown in user profile is populated by WP core. This plugin doesn’t decide the sort order. You can test by deactivating this plugin. And you should still get the same sort order.
I’ll add an item in my to do list, with a low priority, to see if this can be sorted.
Thanks,
Syam
OK, thanks. I came up with the following that seems to work to resort them.
add_filter( 'editable_roles', 't5_sort_editable_roles' );
/**
* Array of roles.
* @wp-hook editable_roles
* @param array $roles
* @return array
*/
function t5_sort_editable_roles( $roles )
{
uasort( $roles, 't5_uasort_editable_roles' );
return $roles;
}
/**
* Compare translated role names.
* @param array $a First role
* @param array $b Second role
* @return number
*/
function t5_uasort_editable_roles( $b, $a )
{
return strcasecmp(
translate_user_role( $a['name'] ),
translate_user_role( $b['name'] )
);
}
Thanks for the tip!
If this works for you, you can add this code to your functions.php to fix this problem.