Answers.Body: <p>Depends what you do in (or with) CiviCRM as to which hooks fire. So, for example, when I go to "Manage Events", I see the following in my logs:</p>
  
  <pre><code>[02-Feb-2018 17:05:56 Europe/London] Array
  (
      [method] =&gt; civicrm_alterAPIPermissions
      [permissions] =&gt; event
      [backtrace] =&gt; #0 /path/to/wp-includes/class-wp-hook.php(288): civicrm_alterAPIPermissions('event')
      ... lots of backtrace ...
  )
  </code></pre>
  
  <p>If I go to "Configure Event - Rain-forest Cup Youth Soccer Tournament" (I've got a test install with the sample data) then I also see:</p>
  
  <pre><code>[02-Feb-2018 17:09:46 Europe/London] Array
  (
      [method] =&gt; civicrm_aclGroup
      [type] =&gt; 4
      [contactID] =&gt; 202
      [tableName] =&gt; civicrm_uf_group
      [allGroups] =&gt; Array
          (
              [10] =&gt; Contribution Bulk Entry
              [13] =&gt; Honoree Individual
              [11] =&gt; Membership Bulk Entry
              [1] =&gt; Name and Address
              [6] =&gt; New Household
              [4] =&gt; New Individual
              [5] =&gt; New Organization
              [9] =&gt; On Behalf Of Organization
              [3] =&gt; Participant Status
              [8] =&gt; Shared Address
              [7] =&gt; Summary Overlay
              [2] =&gt; Supporter Profile
              [12] =&gt; Your Registration Info
          )
  
      [currentGroups] =&gt; 
      [backtrace] =&gt; #0 /path/to/wp-includes/class-wp-hook.php(286): civicrm_aclGroup(4, '202', 'civicrm_uf_grou...', Array, NULL)
      ... lots of backtrace ...
  )
  </code></pre>
  
  <p>If I visit "WordPress Access Control" under Administer -> Users &amp; Permissions, I get:</p>
  
  <pre><code>[02-Feb-2018 17:19:26 Europe/London] Array
  (
      [method] =&gt; civicrm_permission
      [permissions] =&gt; Array
          (
          )
  
      [backtrace] =&gt; #0 /path/to/wp-includes/class-wp-hook.php(286): civicrm_permission(Array)
          ... lots of backtrace ...
  )
  </code></pre>
  
  <p>So, in summary: those hooks <em>do</em> fire -  but only when needed.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-02-02T17:23:28.960Z
Answers.LastActivityDate: 2018-02-02T17:23:28.960Z
Answers.UserDisplayName: Christian Wach
Body: <p>I noticed that some hooks are not firing… I have the following three hooks</p>
  
  <pre><code>&lt;?php
  
  add_filter('civicrm_permission', 'civicrm_permission', 10, 1);
  function civicrm_permission(&amp;$permissions) {
    PC::debug( $permissions, '$permissions' );
  }
  
  add_filter('civicrm_aclGroup', 'civicrm_aclGroup', 10, 5);
  function civicrm_aclGroup( $type, $contactID, $tableName, &amp;$allGroups, &amp;$currentGroups ) {
    PC::debug( $type, '$type' );
    PC::debug( $contactID, '$contactID' );
    PC::debug( $tableName, '$tableName' );
    PC::debug( $allGroups, '&amp;$allGroups' );
    PC::debug( $currentGroups, '$currentGroups' );
  }
  
  add_filter('civicrm_alterAPIPermissions', 'civicrm_alterAPIPermissions', 10, 1);
  function civicrm_alterAPIPermissions(&amp;$permissions) {
    PC::debug( $permissions, '$currentGroups' );
  }
  
  
  ?&gt;
  </code></pre>
  
  <p>the middle one (civicrm_aclGroup) fires, the other two do not. PC::debug is just a logging class. as far as I understood the docs this would be the correct way to target the hooks. </p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2018-02-04T03:03:50.530Z
Comments.Text: Hi Florian! Unless writing code for core, best to use a separate namespace for your code. If your site is `example.org`, you might rename these functions as `exampleorg_permission()` or `exampleorg_civicrm_permission()`, or if you're writing an extension for the community to interface with lolcat API, you might rename them to `lolcatapi_permission()`. The reason for this is so your code doesn't conflict with functions in the CiviCRM namespace - similar named functions [do already exist](https://github.com/civicrm/civicrm-drupal/blob/40acc30a4a3f1d1f7153cb478bba97cd8045c1f3/civicrm.module#L55).
Comments.UserDisplayName: Chris Burgess
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2018-02-04T03:05:21.703Z
Comments.Text: I don't think this is the issue you're facing (the linked function is used in Drupal not WordPress), but it's good to know about these gotchas early so they don't catch you out, and so your code is ready for sharing with the wider community. Good luck!
Comments.UserDisplayName: Chris Burgess
Tags: <wordpress><hooks>
Title: Wordpress hooks – some don't work
ThreadText: # Wordpress hooks – some don't work
  
  (Asked by: username_0 on 2018-02-02)
  
  I noticed that some hooks are not firing… I have the following three hooks
  
  ```
  <?php
  
  add_filter('civicrm_permission', 'civicrm_permission', 10, 1);
  function civicrm_permission(&$permissions) {
    PC::debug( $permissions, '$permissions' );
  }
  
  add_filter('civicrm_aclGroup', 'civicrm_aclGroup', 10, 5);
  function civicrm_aclGroup( $type, $contactID, $tableName, &$allGroups, &$currentGroups ) {
    PC::debug( $type, '$type' );
    PC::debug( $contactID, '$contactID' );
    PC::debug( $tableName, '$tableName' );
    PC::debug( $allGroups, '&$allGroups' );
    PC::debug( $currentGroups, '$currentGroups' );
  }
  
  add_filter('civicrm_alterAPIPermissions', 'civicrm_alterAPIPermissions', 10, 1);
  function civicrm_alterAPIPermissions(&$permissions) {
    PC::debug( $permissions, '$currentGroups' );
  }
  
  ?>
  
  ```
  
  the middle one (civicrm\_aclGroup) fires, the other two do not. PC::debug is just a logging class. as far as I understood the docs this would be the correct way to target the hooks.
  
  **Tags:** wordpress, hooks
  
  > **Comments:**
  > **username_1**: Hi username_0! Unless writing code for core, best to use a separate namespace for your code. If your site is `example.org`, you might rename these functions as `exampleorg_permission()` or `exampleorg_civicrm_permission()`, or if you're writing an extension for the community to interface with lolcat API, you might rename them to `lolcatapi_permission()`. The reason for this is so your code doesn't conflict with functions in the CiviCRM namespace - similar named functions [do already exist](https://github.com/civicrm/civicrm-drupal/blob/40acc30a4a3f1d1f7153cb478bba97cd8045c1f3/civicrm.module#L55).  
  > **username_1**: I don't think this is the issue you're facing (the linked function is used in Drupal not WordPress), but it's good to know about these gotchas early so they don't catch you out, and so your code is ready for sharing with the wider community. Good luck!  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_2 on 2018-02-02. Score: 0 | Accepted answer
  
  Depends what you do in (or with) CiviCRM as to which hooks fire. So, for example, when I go to "Manage Events", I see the following in my logs:
  
  ```
  [02-Feb-2018 17:05:56 Europe/London] Array
  (
      [method] => civicrm_alterAPIPermissions
      [permissions] => event
      [backtrace] => #0 /path/to/wp-includes/class-wp-hook.php(288): civicrm_alterAPIPermissions('event')
      ... lots of backtrace ...
  )
  
  ```
  
  If I go to "Configure Event - Rain-forest Cup Youth Soccer Tournament" (I've got a test install with the sample data) then I also see:
  
  ```
  [02-Feb-2018 17:09:46 Europe/London] Array
  (
      [method] => civicrm_aclGroup
      [type] => 4
      [contactID] => 202
      [tableName] => civicrm_uf_group
      [allGroups] => Array
          (
              [10] => Contribution Bulk Entry
              [13] => Honoree Individual
              [11] => Membership Bulk Entry
              [1] => Name and Address
              [6] => New Household
              [4] => New Individual
              [5] => New Organization
              [9] => On Behalf Of Organization
              [3] => Participant Status
              [8] => Shared Address
              [7] => Summary Overlay
              [2] => Supporter Profile
              [12] => Your Registration Info
          )
  
      [currentGroups] => 
      [backtrace] => #0 /path/to/wp-includes/class-wp-hook.php(286): civicrm_aclGroup(4, '202', 'civicrm_uf_grou...', Array, NULL)
      ... lots of backtrace ...
  )
  
  ```
  
  If I visit "WordPress Access Control" under Administer -> Users & Permissions, I get:
  
  ```
  [02-Feb-2018 17:19:26 Europe/London] Array
  (
      [method] => civicrm_permission
      [permissions] => Array
          (
          )
  
      [backtrace] => #0 /path/to/wp-includes/class-wp-hook.php(286): civicrm_permission(Array)
          ... lots of backtrace ...
  )
  
  ```
  
  So, in summary: those hooks *do* fire - but only when needed.
  
  
  ---
  
  