I've successfully added an additional tab on my woocomerce dashboard titles "Support" using the following code.
function tb_add_support_endpoint() {
add_rewrite_endpoint( 'support', EP_ROOT | EP_PAGES );
}
add_action( 'init', 'tb_add_support_endpoint' );
function tb_support_query_vars( $vars ) {
$vars[] = 'support';
return $vars;
}
enter code here
add_filter( 'query_vars', 'tb_support_query_vars', 0 );
function tb_add_support_link_my_account( $items ) {
$items['support'] = 'Support';
return $items;
}
add_filter( 'woocommerce_account_menu_items', 'tb_add_support_link_my_account' );
function tb_support_content() {
echo '<h3>Support</h3><p>Have a question? Use the form below to get in touch.</p>';
echo do_shortcode( ' [wpforms id="XXX"] ' );
}
add_action( 'woocommerce_account_support_endpoint', 'tb_support_content' );
I would like to add another tab that is only visible to user with the user role "partnersupport"
I used the above code (replacing tb with tbvip) and tried adding:
if ( current_user_can( 'partnersupport' ) ) {
here:
if ( current_user_can( 'partnersupport' ) ) {
function tbvip_add_support_link_my_account( $items ) {
$items['support'] = 'VIP Support';
return $items;
}
}
From what i read on similar thread this should work but it breaks everything for me. Please advise how to achieve my desired outcome.