1

I want to enable access comments, post comments, and post comments without approval for anonymous using drush.

Fresh install, the table entry look like this:

INSERT INTO `permission` VALUES (2,2,'access comments, access content, post comments, post comments without approval',0);

After access comments, post comments, and post comments without approval enabled for anonymous, it looks like this:

INSERT INTO `permission` VALUES (3,1,'access comments, post comments, post comments without approval, access content',0);
INSERT INTO `permission` VALUES (4,2,'access comments, post comments, post comments without approval, access content',0);

I can use drush variable-set error_level "0" to change error reporting level. But how about above case? It looks more difficult to understand

3 Answers 3

3

There is currently no explicit command to run in order to grant a role a certain permission. The documentation is very helpful here - http://www.drush.org/help/5

However, you can use drush to execute native SQL in order to solve the issue

e.g.

drush sql-query "INSERT INTO permission VALUES (4,2,'access comments, post comments, post comments without approval, access content',0)"

If this is something you will be doing on a regular basis after a site install, consider creating your own custom install profile (which will contain the required SQL, or features), or creating your own custom module (e.g. created using features). I imagine having to run this script over CLI is not the most maintainable solution ;)

1
  • Thanks, but it not works. I think something wrong at the 4,2. I tried 9,1 and it works.
    – jibotak
    Feb 19, 2012 at 11:20
1

Use the Permissions API's Drush commands.

1
  • If you follow that link, it gives you help to setting permissions via drush. It just requires that you install the permissions_api module first.
    – alexkb
    Jun 25, 2013 at 1:36
0

For those coming across this post and using Drupal 7, you have two choices.

1.Using SQL, you can run the following

drush sql-query "INSERT INTO role_permission VALUES (<role id>,'<permission>','<module>')"; 

e.g.

drush sql-query "INSERT INTO role_permission VALUES (1,'access comments','comments')"

or

2.Using the Permissions API module, you can run the following:

drush -u 1 perm-grant --roles="anonymous user" --permissions="access comments"

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.