function user_role_load_by_name in Drupal 7
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
3 calls to user_role_load_by_name()
- UserRoleAdminTestCase::testRoleAdministration in modules/
user/ user.test - Test adding, renaming and deleting roles.
- user_admin_role_validate in modules/
user/ user.admin.inc - Form validation handler for the user_admin_role() form.
- user_role_delete in modules/
user/ user.module - Delete a user role from database.
File
- modules/
user/ user.module, line 3015 - 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();
}