Mon 16 Mar 2009
WP: Get Users by Role Function
Posted by Charles Clarkson under PHP, Programming, WordPress
No Comments
John Kolbert wrote a function to to get a list (array) of users by their role name. For example, he shows how to get a list of editors. I would only change the function slightly to accommodate my own programming style (and because I can't leave well enough alone).
As John notes, remember this is for use in the admin panels. Thanks, John.
PHP:
- function get_users_with_role ($role) {
- // gets all users with specified role
- $wp_user_search = new WP_User_Search( '', '', $role);
- return $wp_user_search->get_results();
- }
As John notes, remember this is for use in the admin panels. Thanks, John.
No Responses to “ WP: Get Users by Role Function ”