0

In a custom module I wrote, I implemented hook_og_permission() to define a new group permission.

/**
 * Implements hook_og_permission().
 */
function logic_board_og_permission() {
  return array(
    'rulesprm' => array(
      'title' => t('Rules Form Perm'), 
      'description' => t("Allow og user to fill form"),
    ),
  );
}

I then use the following code to verify the user has that permission, to show some data.

if (user_access('rulesprm')) {
  // …
}

The code doesn't work. Even if the user has that permission, the code inside the if() block isn't executed. Why does this happen?

1 Answer 1

1

user_access() is for core permissions, those added through hook_permission(). For organic groups own permissions hook, you need to use the complementary og_user_access().

if (og_user_access($group_type, $gid, 'rulesprm')) {
  // …
}

See the documentation comment for hook_og_access() given in the og.api.php file, which states:

Permissions are checked using og_user_access().

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.