Skip to content

Instantly share code, notes, and snippets.

@shadcn
Last active April 20, 2016 18:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shadcn/eba959589c8dc075fac132efbcf786e4 to your computer and use it in GitHub Desktop.
Save shadcn/eba959589c8dc075fac132efbcf786e4 to your computer and use it in GitHub Desktop.
Progammatically assign permissions to users in Drupal 8
<?php
use Drupal\user\RoleInterface;
// Allow anonymous and authenticated users to access contact form.
user_role_grant_permissions(RoleInterface::ANONYMOUS_ID, array('access site-wide contact form'));
user_role_grant_permissions(RoleInterface::AUTHENTICATED_ID, array('access site-wide contact form'));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment