Get all wordpress users having a specific role
March 12, 2009
Sometimes as a WordPress plugin developer or a WordPress theme developer, you want to get all of the users with a specific role. For example, all editors. To easily get all users of a role, the first thing to do is to create the function. To do so, paste the following code in your functions.php file: function getAllUsersWithRole($role) { $wp_user_search = new WP_User_Search($usersearch, $userspage, $role); return $wp_user_search->get_results(); } The getAllUsersWithRole() function returns an array containing... [Read the full story]



















