1

i want to assign permissions to a role in my hook_install() , but the permissions that i'm adding are part of my modules hook_permission() don't exist yet? so how to grant permissions role created in hook_install after hook_permission ?

NB :

  • i have D7.23 -
  • my module create the role and his permissions .

    Thanks.

4
  • problem resolved by set permissions in hook_install() user_role_grant_permissions($pub_role_rid,array_keys(module_invoke('my_module', 'permission'))); after creation of my custom role. Dec 11, 2013 at 12:00
  • you can add that as an answer also specify the links to the resources from where you find out. However I wonder whether this is a proper way to achieve it? Dec 11, 2013 at 14:05
  • Possible duplicate of - stackoverflow.com/questions/15972588/… Dec 11, 2013 at 14:08
  • i'm used array_keys(module_invoke('my_module', 'permission') to get only the permissions of ma custom module thanks Mathankumar . Dec 11, 2013 at 18:47

1 Answer 1

0

the solution found in http://www.dibe.gr/blog/drupal-7-create-users-and-roles-programmatically in the author comment , so i'm set only the permissions array of my custom module in hook_install() user_role_grant_permissions($role_rid,array_keys(module_invoke('my_module', 'permission')));

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.