• Resolved theikid

    (@theikid)


    Hello there, thanks for this great plugin! Right now my website as two different product page for my client and for my stockists so they have a different price. I’m planning on using a plugin to use the same product page to be able to show a different price on a role basis. I would love to know if it’s possible to show a custom tab base on a role too as my wholesale role shouldn’t see one of my custom tab. Thank you.

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Contributor yikesitskevin

    (@yikesitskevin)

    Hello @theikid,

    Coincidentally this came up just last week and there’s a support ticket with my explanation on how to do this. It is definitely possible, but you’ll need to add a filter function. Here’s the link to the support ticket – it has an explanation that’s worth reading in my opinion: https://www.ads-software.com/support/topic/how-to-add-product-tab-only-visible-to-admins/.

    There’s a minor mistake in the code there, so here is the updated code:

    add_filter( 'yikes_woo_filter_all_product_tabs', 'yikes_woo_add_tab_permissions', 10, 2 );
    
    function yikes_woo_add_tab_permissions( $tabs, $product ) {
    
    	if ( ! isset( $tabs['google-maps-embed'] ) ) {
    		return $tabs;
    	}
    
    	if ( ! current_user_can( 'administrator' ) ) {
    		unset( $tabs['google-maps-embed'] );
    	}
    
    	return $tabs;
    }

    Let me know how you get along,
    Kevin.

    Thread Starter theikid

    (@theikid)

    Hi Kevin, thanks for the quick reply. I’ll have a look at that post. We can replace ‘administrator’ by any role right? Thanks!

    Plugin Contributor yikesitskevin

    (@yikesitskevin)

    Yes! Sorry I didn’t specify that – the current_user_can() function can accept a role or a capability

    Thread Starter theikid

    (@theikid)

    That’s perfect! Thank you for your help, it will prevent me to check on the user role at the template level ?? Cheers!

    Plugin Contributor yikesitskevin

    (@yikesitskevin)

    Cheers ??

    Thread Starter theikid

    (@theikid)

    Works like a charm actually, thank you for your help.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Hide/Show Custom tab only to specific role?’ is closed to new replies.