Skip to content

Instantly share code, notes, and snippets.

@init90
Created November 13, 2018 16:38
Show Gist options
  • Save init90/74c152c79c0d977dbbaa94de9473100e to your computer and use it in GitHub Desktop.
Save init90/74c152c79c0d977dbbaa94de9473100e to your computer and use it in GitHub Desktop.
Drupal 7, set permissions programality.
$perms = array(
// Node.
"create $bundle_name content",
"edit own $bundle_name content",
"edit any $bundle_name content",
"delete own $bundle_name content",
"delete any $bundle_name content",
// Commerce.
"create commerce_product entities of bundle $bundle_name",
"edit own commerce_product entities of bundle $bundle_name",
"edit any commerce_product entity of bundle $bundle_name",
"view own commerce_product entities of bundle $bundle_name",
"view any commerce_product entity of bundle $bundle_name",
);
$manager_rids = array(
'manager' => 4,
'store_manager' => 7,
);
foreach ($manager_rids as $rid) {
user_role_grant_permissions($rid, $perms);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment