function user_role_load_by_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()

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 3033

Code

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

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.