Answers.Body: <p>The $tabs variable passed into the tabs hook is an array of arrays, with unique identifying values in the "id" column of each entry.  I found a function to scan all elements of the array to check the "id" column for a given value.  This returns the correct $tabs index to use with the unset() function.</p>
  
  <pre><code>function searchForId($id, $array) {
    foreach ($array as $key =&gt; $val) {
      if ($val['id'] === $id) {
        return $key;
      }
    }
    return null;
  }
  </code></pre>
  
  <p>Example usage:</p>
  
  <pre><code>$duestab = searchForId('custom_15', $tabs); //tab holding dues
  unset( $tabs[$duestab] );
  </code></pre>
  
  <p>If my server used PHP 5.5 or greater, I could have skipped the searchForId function and used a one-liner:</p>
  
  <pre><code>$duestab = array_search('custom_15', array_column($tabs, 'id'));
  unset( $tabs[$duestab] );
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-07-02T15:28:43.123Z
Answers.LastActivityDate: 2015-07-02T15:28:43.123Z
Answers.UserDisplayName: Norris
Answers.Body: <p>There is a specific hook to modify the tabs on the Contact Summary. I suggest you use this hook in an extension to make the tabs do what you need them to do? So you could also remove the Contributions tab.
  Example:</p>
  
  <pre><code>function threepeas_civicrm_tabs(&amp;$tabs, $contactID) {
    $threepeasConfig = CRM_Threepeas_Config::singleton();
    /*
     * first check if contact_subtype is country
     */
    if (_threepeasContactIsCountry($contactID) == TRUE) {
      $activeCountryTabs = array('contact_documents', 'rel', 'case', 'activity', 'participant');
      foreach ($tabs as $tabKey =&gt; $tab) {
        $projectWeight = $tab['weight']++;
        if (!in_array($tab['id'], $activeCountryTabs)) {
          unset($tabs[$tabKey]);
        }
      }
  }
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-07-04T22:12:54.603Z
Answers.Text: Yes, that tabs hook is the one we're using.  Your example is a nice option...though it seems to be based on the contact you're viewing, which is different than limiting permissions based on who's viewing the contact.  I suppose you could write the hook to check the viewer permissions, but it seems easier to just use the built in ACL system.
Answers.UserDisplayName: Norris
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-07-03T08:13:42.220Z
Answers.LastActivityDate: 2015-07-03T08:13:42.220Z
Answers.UserDisplayName: ErikH - CiviCooP
Body: <p>We have two different user permission groups: Finance team who can see the Contributions tab, and Personnel, who can't.  We wanted to hide some custom field tabs for both groups, and mimicked the documentation on the civicrm_tabs hook, simply using </p>
  
  <pre><code>unset ($tabs[12]);
  </code></pre>
  
  <p>However, the index 12 corresponds to different tabs for the two types of users, because the count changes depending on whether or not the Contributions tab is visible.</p>
  
  <p>How do we hide tabs in a manner independent of the user group and the other tabs they see?</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-07-03T11:13:14.503Z
Comments.Text: Just as a matter of interest, are you also limiting their ability to export? We're in a similar position, and I'm just wondering how other people are doing it...
Comments.UserDisplayName: Andrew West
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-07-03T17:29:14.870Z
Comments.Text: I'm not sure what you mean by "ability to export", but no, we haven't done anything to limit exporting of anything...just used basic CiviCRM Access Control to distinguish between financial people with access to CiviContribute, vs other people.
Comments.UserDisplayName: Norris
Tags: <hooks>
Title: How can I hide specific tabs in member view regardless of viewer permissions?
ThreadText: # How can I hide specific tabs in member view regardless of viewer permissions?
  
  (Asked by: username_0 on 2015-07-02)
  
  We have two different user permission groups: Finance team who can see the Contributions tab, and Personnel, who can't. We wanted to hide some custom field tabs for both groups, and mimicked the documentation on the civicrm\_tabs hook, simply using
  
  ```
  unset ($tabs[12]);
  
  ```
  
  However, the index 12 corresponds to different tabs for the two types of users, because the count changes depending on whether or not the Contributions tab is visible.
  
  How do we hide tabs in a manner independent of the user group and the other tabs they see?
  
  **Tags:** hooks
  
  > **Comments:**
  > **username_1**: Just as a matter of interest, are you also limiting their ability to export? We're in a similar position, and I'm just wondering how other people are doing it...  
  > **username_0**: I'm not sure what you mean by "ability to export", but no, we haven't done anything to limit exporting of anything...just used basic CiviCRM Access Control to distinguish between financial people with access to CiviContribute, vs other people.  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_0 on 2015-07-02. Score: 2 | Accepted answer
  
  The $tabs variable passed into the tabs hook is an array of arrays, with unique identifying values in the "id" column of each entry. I found a function to scan all elements of the array to check the "id" column for a given value. This returns the correct $tabs index to use with the unset() function.
  
  ```
  function searchForId($id, $array) {
    foreach ($array as $key => $val) {
      if ($val['id'] === $id) {
        return $key;
      }
    }
    return null;
  }
  
  ```
  
  Example usage:
  
  ```
  $duestab = searchForId('custom_15', $tabs); //tab holding dues
  unset( $tabs[$duestab] );
  
  ```
  
  If my server used PHP 5.5 or greater, I could have skipped the searchForId function and used a one-liner:
  
  ```
  $duestab = array_search('custom_15', array_column($tabs, 'id'));
  unset( $tabs[$duestab] );
  
  ```
  
  
  ---
  
  ### Answer by username_2 on 2015-07-03. Score: 1
  
  There is a specific hook to modify the tabs on the Contact Summary. I suggest you use this hook in an extension to make the tabs do what you need them to do? So you could also remove the Contributions tab.
  Example:
  
  ```
  function threepeas_civicrm_tabs(&$tabs, $contactID) {
    $threepeasConfig = CRM_Threepeas_Config::singleton();
    /*
     * first check if contact_subtype is country
     */
    if (_threepeasContactIsCountry($contactID) == TRUE) {
      $activeCountryTabs = array('contact_documents', 'rel', 'case', 'activity', 'participant');
      foreach ($tabs as $tabKey => $tab) {
        $projectWeight = $tab['weight']++;
        if (!in_array($tab['id'], $activeCountryTabs)) {
          unset($tabs[$tabKey]);
        }
      }
  }
  
  ```
  
  > **Comments:**
  > **username_0**: Yes, that tabs hook is the one we're using.  Your example is a nice option...though it seems to be based on the contact you're viewing, which is different than limiting permissions based on who's viewing the contact.  I suppose you could write the hook to check the viewer permissions, but it seems easier to just use the built in ACL system.  
  
  ---
  
  