function user_role_load_by_name

user_role_load_by_name($role_name)

Fetches a user role by role name.

Parameters

$role_name: A string representing the role name.

Return value

A fully-loaded role object if a role with the given name exists, or FALSE otherwise.

See also

user_role_load()

File

modules/user/user.module, line 2991
Enables the user registration and login system.

Code

function user_role_load_by_name($role_name) {
  return db_select('role', 'r')
    ->fields('r')
    ->condition('name', $role_name)
    ->execute()
    ->fetchObject();
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/modules!user!user.module/function/user_role_load_by_name/7.x