Answers.Body: <p>There is a example and information on the <a href="https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_permission/" rel="nofollow noreferrer">hook here</a>.  Throw the hook into your custom module and it should work.  The below example includes a version check that you likely won't need.</p>
  
  <pre><code>function civimonitor_civicrm_permission(&amp;$permissions) {
    $version = CRM_Utils_System::version();
    if (version_compare($version, '4.6.1') &gt;= 0) {
      $permissions += array(
        'access CiviMonitor' =&gt; array(
          ts('Access CiviMonitor', array('domain' =&gt; 'com.aghstrategies.civimonitor')),
          ts('Grants the necessary API permissions for a monitoring user without Administer CiviCRM', array('domain' =&gt; 'com.aghstrategies.civimonitor')),
        ),
      );
    }
    else {
      $permissions += array(
        'access CiviMonitor' =&gt; ts('Access CiviMonitor', array('domain' =&gt; 'com.aghstrategies.civimonitor')),
      );
    }
  }
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-04-05T09:49:12.783Z
Answers.Text: In my scenario, only admin can see but authenticate user should not access these extension pages. How to do that?
Answers.UserDisplayName: deepak
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-04-05T09:55:18.737Z
Answers.Text: Think this is what you are after: https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_permission_check/ . I haven't had to implemented it before, but that seems like the correct route to follow.  Imagine someone else can probably feedback with more detail but best path could be to look at how existing extensions function.
Answers.UserDisplayName: EagleUK
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-04-05T10:17:16.557Z
Answers.Text: I am not understanding. Is there any simple extension or snippets to understand permission hooks?
Answers.UserDisplayName: deepak
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-04-05T10:33:57.237Z
Answers.Text: @deepak Have you worked much with Drupal permissions before? If not probably a good place to start then move on to doing what you need to do with civi perms :).  This will give you a basic look at a drupal module that uses permissions for page access: https://www.drupal.org/docs/7/creating-custom-modules/specifying-a-custom-permission-for-a-new-page
Answers.UserDisplayName: EagleUK
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-04-05T10:57:33.473Z
Answers.Text: Hello@EagleUK I created a page(using civix tool) but that page must access only a site admin and does not access to other authenticated users.
Answers.UserDisplayName: deepak
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-04-05T13:41:51.550Z
Answers.Text: Thank you buddy, finally it's done.
Answers.UserDisplayName: deepak
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-04-05T09:44:48.467Z
Answers.LastActivityDate: 2019-04-05T09:44:48.467Z
Answers.UserDisplayName: EagleUK
Body: <p>I am developing an extension. I want to provide permissions using drupal.</p>
  
  <p><a href="https://i.sstatic.net/PA5bv.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/PA5bv.png" alt="enter image description here"></a></p>
  
  <p>I am using following hook for creating a permission</p>
  
  <pre><code>hook_civicrm_permission(&amp;$permissions);
  </code></pre>
  
  <p>But, how to do that (means can view or edit some custom data)?
  Please suggest some similar extensions.</p>
  
Tags: <drupal><extension><permissions><hooks>
Title: How to set a permission using drupal ACL?
ThreadText: # How to set a permission using drupal ACL?
  
  (Asked by: username_0 on 2019-04-05)
  
  I am developing an extension. I want to provide permissions using drupal.
  
  I am using following hook for creating a permission
  hook_civicrm_permission(&$permissions);
  
  But, how to do that (means can view or edit some custom data)?
  Please suggest some similar extensions.
  
  **Tags:** drupal, extension, permissions, hooks
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2019-04-05. Score: 1
  
  There is a example and information on the hook here.  Throw the hook into your custom module and it should work.  The below example includes a version check that you likely won't need.
  function civimonitor_civicrm_permission(&$permissions) {
    $version = CRM_Utils_System::version();
    if (version_compare($version, '4.6.1') >= 0) {
      $permissions += array(
        'access CiviMonitor' => array(
          ts('Access CiviMonitor', array('domain' => 'com.aghstrategies.civimonitor')),
          ts('Grants the necessary API permissions for a monitoring user without Administer CiviCRM', array('domain' => 'com.aghstrategies.civimonitor')),
        ),
      );
    }
    else {
      $permissions += array(
        'access CiviMonitor' => ts('Access CiviMonitor', array('domain' => 'com.aghstrategies.civimonitor')),
      );
    }
  }
  
  > **Comments:**
  > **username_0**: In my scenario, only admin can see but authenticate user should not access these extension pages. How to do that?  
  > **username_1**: Think this is what you are after: https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_permission_check/ . I haven't had to implemented it before, but that seems like the correct route to follow.  Imagine someone else can probably feedback with more detail but best path could be to look at how existing extensions function.  
  > **username_0**: I am not understanding. Is there any simple extension or snippets to understand permission hooks?  
  > **username_1**: @username_0 Have you worked much with Drupal permissions before? If not probably a good place to start then move on to doing what you need to do with civi perms :).  This will give you a basic look at a drupal module that uses permissions for page access: https://www.drupal.org/docs/7/creating-custom-modules/specifying-a-custom-permission-for-a-new-page  
  > **username_0**: Hello@username_1 I created a page(using civix tool) but that page must access only a site admin and does not access to other authenticated users.  
  > **username_0**: Thank you buddy, finally it's done.  
  
  ---
  
  