• Role IDs no longer exist; they are replaced by new role (machine) names.
  • The rid column in the users_roles table is now a varchar role column.
  • Old role "names" are now "labels".
  • DRUPAL_ANONYMOUS_RID is now renamed to BACKDROP_ANONYMOUS_ROLE and its value is 'anonymous' instead of the integer 1.
  • DRUPAL_AUTHENTICATED_RID is now renamed to BACKDROP_AUTHENTICATED_ROLE and its value is 'authenticated' instead of the integer 2.
  • user_role_load() now takes the role name as its argument instead of role ID.
  • user_role_load_by_name() has been removed, since all roles are loaded by names now.
  • user_roles() now returns an array of machine_name => label values, instead of role_id => role_names.
  • user_roles() now has a 3rd argument $full_objects for loading complete user role objects, instead of returning just labels.
  • The structure of a role object is changed to accommodate the new machine names and labels.

    Drupal 7:

    $user_role->rid = 5;
    $user_role->name = 'my role name';


    $user_role->name = 'my_role_name';
    $user_role->label = 'My role label';
  • The list of roles in $user->roles is now an unindexed array of user role names, rather than IDs and names.
    Drupal 7:
    $user->roles = array(
      2 => 'authenticated user',
      3 => 'administrator',

    $user->roles = array('authenticated', 'administrator');
    This means that checking user roles is now done by checking the value of the roles array, rather than the keys:

    Drupal 7:
    $has_role = isset($user->roles[BACKDROP_AUTHENTICATED_RID]);

    $has_role = in_array(BACKDROP_AUTHENTICATED_ROLE, $user->roles);

Upgrading from Drupal 7

When upgrading from Drupal 7, Backdrop names the new configuration file for each role based on the ID which the role had in Drupal 7. So a role with RID = 3 will get a config file named user.role.3.json, and the name key in the config file will be name: 3.

Also, the output of user_roles() on an upgraded Drupal 7 site will -for example- be:

  'anonymous' => 'Anonymous',
  'authenticated' => 'Authenticated',
  3 => 'Administrator',
  4 => 'My custom role',

So previous roles IDs are preserved that way, in case any contrib or custom module requires to use the RIDs to provide an upgrade path.
Introduced in branch: 
Introduced in version: 
Module developers
Related Github Issues: