0

I have implemented hook_og_permission() in a custom module.

/**
* 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"),
    ),
  );
}

Using this permission like in the following code doesn't work: The code inside the if() statement is not executed.

    if (user_access('rulesprm')) {
      // Some code
    }

Why?

1

user_access is for core permissions, I.e. those added through hook_permission. For organic groups’ own permissions hook, you need to use the complementary og_user_access:, eg:

if (og_user_access($group_type, $gid, 'rulesprm')) {
  ...
}
| improve this answer | |
  • I am using this og_user_access($group_type, $gid, 'rulesprm')) but still not display any data with this condition. – user82753 Mar 21 '18 at 18:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy