Skip to content

Instantly share code, notes, and snippets.

@danemorgan
Created September 14, 2013 05:30
Show Gist options
  • Select an option

  • Save danemorgan/6559061 to your computer and use it in GitHub Desktop.

Select an option

Save danemorgan/6559061 to your computer and use it in GitHub Desktop.
Get the number of users currently assigned to specified role.
function count_users_by_role( $user_role ) {
// Standard User Roles: all, administrator, editor, author, contributor, subscriber
$result = count_users();
$totalUsers = $result['total_users'];
if( 'all' == $user_roll || '' == $user_roll ) :
return $totalUsers;
else :
return $result['avail_roles'][$type];
endif;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment