How to create a new role with authenticated user permissions I want to create a new role. New role should have all the permissions of authenticated user as well as the some new permissions.

I used the following code,

$role = new stdClass();
$role-&gt;name = 'New role';

// load the authenticated user role
$auth_role = user_role_load(DRUPAL_AUTHENTICATED_RID);
$role-&gt;weight = $auth_role-&gt;weight + 1;

user_role_save($role);


and I will assign the permissions using user_role_change_permissions() or user_role_grant_permissions()

Now I want to assign the authenticated user permissions to this new role. How to achieve this?
Got it. following code will achieve the this functionality,

$role = new stdClass();
$role-&gt;name = 'New role';
// load the authenticated user role
$auth_role = user_role_load(DRUPAL_AUTHENTICATED_RID);
// Give the weight more than authenticate user, so that
// New role will have all the authenticated user permissions
// by default.
$role-&gt;weight = $auth_role-&gt;weight + 1;
user_role_save($role);
$auth_permissions = user_role_permissions(array(DRUPAL_AUTHENTICATED_RID =&gt; 'authenticated users'));
$auth_permissions += array('other permissions');
// Grant permissions to our 'New role' role
user_role_grant_permissions($role-&gt;rid, array_keys($auth_permissions[DRUPAL_AUTHENTICATED_RID]));