You are here

function hook_og_permission in Organic groups 7.2

Same name and namespace in other branches
  1. 7 og.api.php \hook_og_permission()

Define permissions specific to organic groups.

This hook can supply permissions that the module defines, so that they can be selected on the group permissions page and used to grant or restrict access to actions pertaining to groups.

Permissions are checked using og_user_access().

Return value

array An array whose keys are permission names and whose corresponding values are arrays containg the following key-value pairs:

  • title: The human-readable name of the permission, to be shown on group permissions pages. This should be wrapped in the t() function so it can be translated.
  • description: (optional) A description of what the permission does. This should be wrapped in the t() function so it can be translated.
  • roles: (optional) An array of OG roles to which it is possible to assign this permission. The default value is an array containg OG_ANONYMOUS_ROLE and OG_AUTHENTICATED_ROLE.
  • default role: (optional) An array of OG roles that should be assigned this permission by default. If omitted then no role will receive the permission by default.
3 functions implement hook_og_permission()

Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.

og_field_access_og_permission in og_field_access/og_field_access.module
Implements hook_og_permission().
og_og_permission in ./og.module
Implements hook_og_permission().
og_ui_og_permission in og_ui/og_ui.module
Implement hook_og_permission().
2 invocations of hook_og_permission()
og_get_permissions in ./og.module
Get all permissions defined by implementing modules.
og_ui_admin_permissions in og_ui/og_ui.admin.inc
Menu callback: administer permissions.

File

./og.api.php, line 38
Hooks provided by the Organic groups module.

Code

function hook_og_permission() {
  return array(
    'subscribe' => array(
      'title' => t('Subscribe user to group'),
      'description' => t("Allow user to be a member of a group (approval required)."),
      // Determine to which role to limit the permission. For example the
      // "subscribe" can't be assigned only to a non-member, as a member doesn't
      // need it.
      'roles' => array(
        OG_ANONYMOUS_ROLE,
      ),
      // Determine to which roles the permissions will be enabled by default.
      'default role' => array(
        OG_ANONYMOUS_ROLE,
      ),
    ),
  );
}