Title: Hide Custom Tabs
Last modified: December 28, 2021

---

# Hide Custom Tabs

 *  Resolved [paigettie](https://wordpress.org/support/users/paigettie/)
 * (@paigettie)
 * [4 years, 5 months ago](https://wordpress.org/support/topic/hide-custom-tabs-2/)
 * Read through the forum and found a couple of posts that seemed to fit my need.
   applies this code (given in each of the replies) to the functions.php. Unfortunately
   I can still see SRP tab and info even though I’m in not logged in or in incognito
   mode. Am I missing something or does this code no longer work? Thanks in advance!
   So appreciated!
 * add_filter(
    ‘yikes_woo_filter_all_product_tabs’, function( $tabs ) { if ( ! 
   is_user_logged_in() ) { unset( $tabs[‘SRP’] ); } return $tabs; } );
 * The page I need help with: _[[log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Fhide-custom-tabs-2%2F%3Foutput_format%3Dmd&locale=en_US)
   to see the link]_

Viewing 15 replies - 1 through 15 (of 17 total)

1 [2](https://wordpress.org/support/topic/hide-custom-tabs-2/page/2/?output_format=md)
[→](https://wordpress.org/support/topic/hide-custom-tabs-2/page/2/?output_format=md)

 *  Thread Starter [paigettie](https://wordpress.org/support/users/paigettie/)
 * (@paigettie)
 * [4 years, 5 months ago](https://wordpress.org/support/topic/hide-custom-tabs-2/#post-15204538)
 * I’ve also tried this code and the SRP tab is still showing when incognito:
 * add_filter(
    ‘yikes_woo_filter_all_product_tabs’, ‘yikes_woo_hide_tabs_from_non_logged_in_users’,
   10, 2 );
 * function yikes_woo_hide_tabs_from_non_logged_in_users( $tabs, $product ) {
 *  if ( isset( $tabs[‘SRP’] ) && ! is_user_logged_in() ) {
    unset( $tabs[‘SRP’]);}
 *  return $tabs;
    };
    -  This reply was modified 4 years, 5 months ago by [paigettie](https://wordpress.org/support/users/paigettie/).
 *  Plugin Contributor [Tracy Levesque](https://wordpress.org/support/users/liljimmi/)
 * (@liljimmi)
 * 🏳️‍🌈 YIKES, Inc. Co-Owner
 * [4 years, 5 months ago](https://wordpress.org/support/topic/hide-custom-tabs-2/#post-15204581)
 * Hi [@paigettie](https://wordpress.org/support/users/paigettie/)
 * What are you trying to do exactly? Only show the tab to logged-in users?
 * Thank you.
    -Tracy
 *  Thread Starter [paigettie](https://wordpress.org/support/users/paigettie/)
 * (@paigettie)
 * [4 years, 5 months ago](https://wordpress.org/support/topic/hide-custom-tabs-2/#post-15204587)
 * Yes, only show that particular custom tab to users who are logged in. =)
 *  Thread Starter [paigettie](https://wordpress.org/support/users/paigettie/)
 * (@paigettie)
 * [4 years, 5 months ago](https://wordpress.org/support/topic/hide-custom-tabs-2/#post-15208329)
 * [@liljimmi](https://wordpress.org/support/users/liljimmi/)
    Thanks for responding,
   yes, I’m trying to only show one particular custom tab only to users who are 
   logged in.
 * Thanks!
 *  [jpowersdev](https://wordpress.org/support/users/jpowersdev/)
 * (@jpowersdev)
 * [4 years, 5 months ago](https://wordpress.org/support/topic/hide-custom-tabs-2/#post-15214907)
 * Hi [@paigettie](https://wordpress.org/support/users/paigettie/),
 * Are you sure the tab’s array key is SRP in this instance? You may want to var_dump
   the whole array to be sure.
 * Alternatively, you might increase the filter’s priority to ensure it runs later.
 * Let me know if that helps,
    Jon
 *  Thread Starter [paigettie](https://wordpress.org/support/users/paigettie/)
 * (@paigettie)
 * [4 years, 5 months ago](https://wordpress.org/support/topic/hide-custom-tabs-2/#post-15215305)
 * Hi [@jpowersdev](https://wordpress.org/support/users/jpowersdev/), thanks for
   jumping in. =)
 * I’m probably going to come off sounding very ignorant, I’m a newbie and know 
   just enought code to change colors for buttons and copy code and see how to adjust
   it to make it work (usually, not always) for the slight variations I’m needing.
   So that said:
 * By “tab’s array key” being SRP, this is the Tab Title, correct? (there is tab
   title, tab name, tab content preview) So, the tab title is SRP. If the tab array
   key is not the tab title, where do I look to verify the array key?
 * Assuming that the array key IS the tab title, How do I var_dump? This is a new
   concept to me.
 * As I was checking the custom tabs settings I did just realize there is the option
   to Toggle the_content filter, so since we are using Elementor I did toggle and
   save that, unfortunately it did not help. How would I increase the filter’s priority(
   assuming the var_dump doesn’t work)?
 * Thank you so much!!
 *  [jpowersdev](https://wordpress.org/support/users/jpowersdev/)
 * (@jpowersdev)
 * [4 years, 5 months ago](https://wordpress.org/support/topic/hide-custom-tabs-2/#post-15215335)
 * Hi [@paigettie](https://wordpress.org/support/users/paigettie/),
 * So the tabs are stored as an associative array, i.e.
 *     ```
       $tabs = array(
         'first' => array(
           'title' => 'Tab Title',
           ... etc.
         )
       );
       ```
   
 * Each tab has a key in that array. In the above case, the key is `first`. That
   key should be the title, but it might be all lowercase, for example.
 * `var_dump` is a function that lets you output a variable. In this case, you’d
   want to output the tabs: `var_dump($tabs);`. That will let you inspect the tab
   data array, allowing you to see the keys and use `unset` on the correct array
   member.
 * To increase the priority, you change the third parameter of the `add_filter` 
   function. Currently, it’s set to 10. You could change it to 20, for example, 
   and it would execute later than other functions that use that filter with a priority
   of 10.
 * Jon
 *  Thread Starter [paigettie](https://wordpress.org/support/users/paigettie/)
 * (@paigettie)
 * [4 years, 5 months ago](https://wordpress.org/support/topic/hide-custom-tabs-2/#post-15215672)
 * [@jpowersdev](https://wordpress.org/support/users/jpowersdev/)
 * Okay, thank you, this is beginning to become a bit less murky and make sense.
   My next question would be, where do I perform the var_dump($tabs); to see the
   keys to verify or correct the code to hide the tab? Do I run that if the functions.
   php, or is there a plugin that I should be using that will return that info?
   
   Again, thank you both for your help and your patience. =)
 *  [jpowersdev](https://wordpress.org/support/users/jpowersdev/)
 * (@jpowersdev)
 * [4 years, 5 months ago](https://wordpress.org/support/topic/hide-custom-tabs-2/#post-15215677)
 * Hi [@paigettie](https://wordpress.org/support/users/paigettie/),
 * You can do that inside the filter function you’ve already defined, presumably
   in your `functions.php` file.
 * You’re welcome!
 * Jon
 *  Thread Starter [paigettie](https://wordpress.org/support/users/paigettie/)
 * (@paigettie)
 * [4 years, 5 months ago](https://wordpress.org/support/topic/hide-custom-tabs-2/#post-15219552)
 * [@jpowersdev](https://wordpress.org/support/users/jpowersdev/)
 * Okay, I pasted this:
 * var_dump($tabs);
 * in the funtions.php of the theme and clicked “update file”. It returned “file
   edited successfully”, but it didn’t create the tabs associative array. =( Should
   I be looking elsewhere for it? I feel like I’m missing something obvious… like
   it should be right in front of me and probably is, and somehow I’m not seeing
   it.
 *  Thread Starter [paigettie](https://wordpress.org/support/users/paigettie/)
 * (@paigettie)
 * [4 years, 5 months ago](https://wordpress.org/support/topic/hide-custom-tabs-2/#post-15219593)
 * [@jpowersdev](https://wordpress.org/support/users/jpowersdev/)
 * I GOT IT!!!! I thought, wait, if I inspect the page, maybe I can find the tab
   array there, and tried it! Turns out the tab array key was #tab-srp so I put 
   that in the code and it’s working!!! Even though I didn’t get the var_dump, I
   really appreciate the guidance with understanding the array sequence and the 
   help you gave that encouraged me to see if I could find the correct key another
   way!
 * THANK YOU!!!!!!!!!
 *  Thread Starter [paigettie](https://wordpress.org/support/users/paigettie/)
 * (@paigettie)
 * [4 years, 5 months ago](https://wordpress.org/support/topic/hide-custom-tabs-2/#post-15219599)
 * [@jpowersdev](https://wordpress.org/support/users/jpowersdev/)
 * Wait, celebrated too soon. It worked when I checked it, then didn’t work after
   having the client check it and I’m back to seeing it again. arg! I’m so confused!!
 *  Thread Starter [paigettie](https://wordpress.org/support/users/paigettie/)
 * (@paigettie)
 * [4 years, 5 months ago](https://wordpress.org/support/topic/hide-custom-tabs-2/#post-15225896)
 * [@jpowersdev](https://wordpress.org/support/users/jpowersdev/) [@liljimmi](https://wordpress.org/support/users/liljimmi/)
 * Since I basically ended up back at square one, I added the var_dump like this:
 *     ```
       add_filter(
       ‘yikes_woo_filter_all_product_tabs’, ‘yikes_woo_hide_tabs_from_non_logged_in_users’, 10, 2 );
   
       function yikes_woo_hide_tabs_from_non_logged_in_users( $tabs, $product ) {
       var_dump( $tabs );
       if ( isset( $tabs[‘srp’] ) && ! is_user_logged_in() ) {
       unset( $tabs[‘srp’] );
       }
   
       return $tabs;
       };
       ```
   
 * First, is this correct? Second, regarding where I’m supposed to visually be able
   to see the output from the var_dump, I found a thread that said after updating
   the function.php to go to the single product page and the name of the tab would
   be listed there, but the page looks exactly the same to me… =( I think that is
   currently the biggest issue I’m having, I am not seeing anything by having a 
   var_dump listed as above, or by itself.
 * Is there any chance that using Elementor and a Child theme would be contributing
   to the difficulty?
 *  [jpowersdev](https://wordpress.org/support/users/jpowersdev/)
 * (@jpowersdev)
 * [4 years, 5 months ago](https://wordpress.org/support/topic/hide-custom-tabs-2/#post-15226065)
 * Hi [@paigettie](https://wordpress.org/support/users/paigettie/),
 * Instead of `yikes_woo_filter_all_product_tabs`, try using the `woocommerce_product_tabs`
   filter as shown here: [https://woocommerce.com/document/editing-product-data-tabs/#section-1](https://woocommerce.com/document/editing-product-data-tabs/#section-1).
   You’ll also need to update the callback function to only accept one parameter;`
   $tabs`.
 * Let me know if that helps,
    Jon
 *  Thread Starter [paigettie](https://wordpress.org/support/users/paigettie/)
 * (@paigettie)
 * [4 years, 5 months ago](https://wordpress.org/support/topic/hide-custom-tabs-2/#post-15226438)
 * [@jpowersdev](https://wordpress.org/support/users/jpowersdev/)
 * Forward progress…. I don’t know if this is what you meant, but his is what I 
   put in the php:
 *     ```
       add_filter( 'woocommerce_product_tabs', 'woo_remove_product_tabs', 98 );
   
       function woo_remove_product_tabs( $tabs ) {
   
           unset( $tabs['srp'] );      	// Remove the srp tab
   
           return $tabs;
       }
       ```
   
 * This successfully hides the tab for everyone, so now do I add this:
 * `if ( isset( $tabs[‘srp’] ) && ! is_user_logged_in() )`
 * before this:
 *     ```
       {
       unset( $tabs[‘srp’] ); 
       ```
   
 * to hide the tab if not logged in?
 * I hope you really feel my appreciation for your help. =)

Viewing 15 replies - 1 through 15 (of 17 total)

1 [2](https://wordpress.org/support/topic/hide-custom-tabs-2/page/2/?output_format=md)
[→](https://wordpress.org/support/topic/hide-custom-tabs-2/page/2/?output_format=md)

The topic ‘Hide Custom Tabs’ is closed to new replies.

 * ![](https://ps.w.org/yikes-inc-easy-custom-woocommerce-product-tabs/assets/icon-
   256x256.png?rev=1558461)
 * [Custom Product Tabs for WooCommerce](https://wordpress.org/plugins/yikes-inc-easy-custom-woocommerce-product-tabs/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/yikes-inc-easy-custom-woocommerce-product-tabs/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/yikes-inc-easy-custom-woocommerce-product-tabs/)
 * [Active Topics](https://wordpress.org/support/plugin/yikes-inc-easy-custom-woocommerce-product-tabs/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/yikes-inc-easy-custom-woocommerce-product-tabs/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/yikes-inc-easy-custom-woocommerce-product-tabs/reviews/)

 * 17 replies
 * 3 participants
 * Last reply from: [jpowersdev](https://wordpress.org/support/users/jpowersdev/)
 * Last activity: [4 years, 5 months ago](https://wordpress.org/support/topic/hide-custom-tabs-2/page/2/#post-15236614)
 * Status: resolved