Answers.Body: <p>hook_civicrm_tabs is now deprecated and you should use <a href="https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_tabset" rel="nofollow noreferrer">https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_tabset</a>.</p>
  <p>Also note:</p>
  <pre><code>// $url should return in 4.4 and prior an HTML snippet e.g. '&lt;div&gt;&lt;p&gt;....';
  // in 4.5 and higher this needs to be encoded in json. E.g. json_encode(array('content' =&gt; &lt;html form snippet as previously provided&gt;));
  // or CRM_Core_Page_AJAX::returnJsonResponse($content) where $content is the html code
  // in the first cases you need to echo the return and then exit, if you use CRM_Core_Page method you do not need to worry about this.
  </code></pre>
  <p>Some example code:</p>
  <pre><code>function koba_civicrm_tabset($tabsetName, &amp;$tabs, $context) {
    //check if the tab set is Event manage
    if ($tabsetName == 'civicrm/event/manage') {
      // Remove &quot;Mond aan mond reclame&quot; tab
      unset($tabs['friend']);
      // Remove &quot;Location&quot; tab: we use a contact subtype for location because it has better integration
      unset($tabs['location']);
      // Remove &quot;Personal campaign pages&quot;: we don't use this
      unset($tabs['pcp']);
  
  
      // Add a Beheer Bijscholingen tab, a tab that shows a Drupal view
      if (!empty($context)) {
        $eventID = $context['event_id'];
        $url = CRM_Utils_System::url('admin/sitename/bijscholingen/json');
        $result = views_get_view_result('beheer_sitename_bijscholingen', 'page', $eventID);
        $count = count($result);
        $tabs['beheer'] = array(
            'weight' =&gt; 300,
            'count' =&gt; $count,
            'title' =&gt; ts('Beheer'),
            'link' =&gt; $url,
            'valid' =&gt; 1,
            'active' =&gt; 1,
            'current' =&gt; false,
        );
      }
    }
  }
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2016-01-20T10:25:35.507Z
Answers.LastActivityDate: 2020-09-18T19:41:08.763Z
Answers.LastEditDate: 2020-09-18T19:41:08.763Z
Answers.UserDisplayName: Hans Rossel
Answers.Body: <p>The hook_civicrm_tabs is called by CiviCRM and provide the contactID argument. You don't need to use <code>add_action(...)</code> to call the hook.</p>
  
  <p>Your example should work as is if you put it in a CiviCRM extension called civitest. </p>
  
  <p>If you need help getting started with extension development, you can start with <a href="http://wiki.civicrm.org/confluence/display/CRMDOC/Create+a+Module+Extension" rel="nofollow">CiviCRM Wiki</a> </p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-01-20T17:56:37.333Z
Answers.Text: This depends a bit on how the code is packaged. For a WordPress plugin, one would explicitly register the function using `add_action()`. For a Civi extension or Drupal module, there's no equivalent to `add_action()` because everything is based off naming conventions.
Answers.UserDisplayName: Tim Otten
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-04-10T16:22:11.107Z
Answers.LastActivityDate: 2015-04-10T16:22:11.107Z
Answers.UserDisplayName: samuelsov
Body: <p>I create a new plugin and I try to use hook for adding extra tab in the contents, my question is how to get $contactID?</p>
  
  <pre><code>add_action('civicrm_tabs', ' civitest_civicrm_tabs');
  
  function civitest_civicrm_tabs( &amp;$tabs, $contactID ) {
  
    // unset the contribition tab, i.e. remove it from the page
    unset( $tabs[1] );
  
    // let's add a new "contribution" tab with a different name and put it last
    // this is just a demo, in the real world, you would create a url which would
    // return an html snippet etc.
    $url = CRM_Utils_System::url( 'civicrm/contact/view/contribution',
                                  "reset=1&amp;snippet=1&amp;force=1&amp;cid=$contactID" );
    $tabs[] = array( 'id'    =&gt; 'mySupercoolTab',
                     'url'   =&gt; $url,
                     'title' =&gt; 'Contribution Tab Renamed',
                     'weight' =&gt; 300 );
  }
  </code></pre>
  
  <p>Thank you</p>
  
  <p>Nilda</p>
  
Tags: <wordpress><hooks>
Title: How do I add new tab to the Contact Summary Page?
ThreadText: # How do I add new tab to the Contact Summary Page?
  
  (Asked by: username_0 on 2015-04-10)
  
  I create a new plugin and I try to use hook for adding extra tab in the contents, my question is how to get $contactID?
  
  ```
  add_action('civicrm_tabs', ' civitest_civicrm_tabs');
  
  function civitest_civicrm_tabs( &$tabs, $contactID ) {
  
    // unset the contribition tab, i.e. remove it from the page
    unset( $tabs[1] );
  
    // let's add a new "contribution" tab with a different name and put it last
    // this is just a demo, in the real world, you would create a url which would
    // return an html snippet etc.
    $url = CRM_Utils_System::url( 'civicrm/contact/view/contribution',
                                  "reset=1&snippet=1&force=1&cid=$contactID" );
    $tabs[] = array( 'id'    => 'mySupercoolTab',
                     'url'   => $url,
                     'title' => 'Contribution Tab Renamed',
                     'weight' => 300 );
  }
  
  ```
  
  Thank you
  
  username_0
  
  **Tags:** wordpress, hooks
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_1 on 2016-01-20. Score: 4
  
  hook\_civicrm\_tabs is now deprecated and you should use <https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_tabset>.
  
  Also note:
  
  ```
  // $url should return in 4.4 and prior an HTML snippet e.g. '<div><p>....';
  // in 4.5 and higher this needs to be encoded in json. E.g. json_encode(array('content' => <html form snippet as previously provided>));
  // or CRM_Core_Page_AJAX::returnJsonResponse($content) where $content is the html code
  // in the first cases you need to echo the return and then exit, if you use CRM_Core_Page method you do not need to worry about this.
  
  ```
  
  Some example code:
  
  ```
  function koba_civicrm_tabset($tabsetName, &$tabs, $context) {
    //check if the tab set is Event manage
    if ($tabsetName == 'civicrm/event/manage') {
      // Remove "Mond aan mond reclame" tab
      unset($tabs['friend']);
      // Remove "Location" tab: we use a contact subtype for location because it has better integration
      unset($tabs['location']);
      // Remove "Personal campaign pages": we don't use this
      unset($tabs['pcp']);
  
      // Add a Beheer Bijscholingen tab, a tab that shows a Drupal view
      if (!empty($context)) {
        $eventID = $context['event_id'];
        $url = CRM_Utils_System::url('admin/sitename/bijscholingen/json');
        $result = views_get_view_result('beheer_sitename_bijscholingen', 'page', $eventID);
        $count = count($result);
        $tabs['beheer'] = array(
            'weight' => 300,
            'count' => $count,
            'title' => ts('Beheer'),
            'link' => $url,
            'valid' => 1,
            'active' => 1,
            'current' => false,
        );
      }
    }
  }
  
  ```
  
  
  ---
  
  ### Answer by username_2 on 2015-04-10. Score: 2
  
  The hook\_civicrm\_tabs is called by CiviCRM and provide the contactID argument. You don't need to use `add_action(...)` to call the hook.
  
  Your example should work as is if you put it in a CiviCRM extension called civitest.
  
  If you need help getting started with extension development, you can start with [CiviCRM Wiki](http://wiki.civicrm.org/confluence/display/CRMDOC/Create+a+Module+Extension)
  
  > **Comments:**
  > **username_3**: This depends a bit on how the code is packaged. For a WordPress plugin, one would explicitly register the function using `add_action()`. For a Civi extension or Drupal module, there's no equivalent to `add_action()` because everything is based off naming conventions.  
  
  ---
  
  