Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
function HOOK_og_permission() {
$perms = array();
$perms['disabled example'] = array(
'title' => t('Disabled example'),
'description' => t('Demonstrates how you cannot enable this permission for specified roles only.'),
'roles' => array(OG_ADMINISTRATOR_ROLE),
'default role' => array(OG_ADMINISTRATOR_ROLE),
);
$perms['enabled example'] = array(
'title' => t('Enabled example'),
'description' => t('Demonstrates how you can now enable this permission.'),
'roles' => array(OG_AUTHENTICATED_ROLE, OG_ADMINISTRATOR_ROLE),
'default role' => array(OG_ADMINISTRATOR_ROLE),
);
return $perms;
}
I would expect the 'disabled example' perm to allow me to enable it for the administrator role, but that is not the case. This code:
if ($disable || (empty($perm['roles']) || empty($perm['roles'][OG_AUTHENTICATED_ROLE]))) {
foreach ($auth_rids as $auth_rid) {
if (in_array($auth_rid, array_keys($role_names))) {
$form['checkboxes'][$auth_rid][$key]['#attributes']['disabled'] = TRUE;
}
}
}
From og_ui_admin_permissions_after_build in og_ui.admin.inc will disable all checkboxes if OG_AUTHENTICATED_ROLE is not specified.