1

I have a content type which I am creating on install profile, and I want to create a user that has permissions to edit that content type. How do I create user roles and permissions for those roles in the install profile?

1 Answer 1

3

To add a role you can use user_role_save():

$role = new stdClass();
$role->name = 'role_name';
$role->weight = 5;
user_role_save($role);

To grant specific permissions to a role you can use user_role_grant_permissions():

$grant = array('access content', 'access comments', 'etc...');
user_role_grant_permissions($role->rid, $grant);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.