Hi. How can we help?

How to show Stripe Connect menu only for Vendors (or other users)

You can show the Stripe Connect menu item only for Vendor adding the following custom code in the functions.php file of your active theme:

<?php
if (class_exists('YITH_Stripe_Connect')){


if ( !function_exists('yith_wcsc_account_menu_item_custom' ) ){
function yith_wcsc_account_menu_item_custom($items){
$user_id = get_current_user_id();
$available_role = 'yith_vendor';
if ( $user_id ) {
$user_meta = get_userdata($user_id);
$user_roles = $user_meta->roles;
if( ! in_array( $available_role, $user_roles) ) {
unset($items['stripe-connect']);
}
}
return $items;
}

add_filter('yith_wcsc_account_menu_item', 'yith_wcsc_account_menu_item_custom');
}



if (!function_exists('yith_wcsc_disable_stripe_connect_account_page')){
function yith_wcsc_disable_stripe_connect_account_page(){

$user_id = get_current_user_id();
$available_role = 'yith_vendor';
if ( $user_id ) {
$user_meta = get_userdata($user_id);
$user_roles = $user_meta->roles;
if( ! in_array( $available_role, $user_roles) ) {
remove_action( 'woocommerce_account_stripe-connect_endpoint', array( YITH_Stripe_Connect::instance()->frontend, 'print_account_page' ) );
}
}
}

add_action('init', 'yith_wcsc_disable_stripe_connect_account_page');
}
}
Was this article helpful?
0 out of 4 found this helpful

Back to Help Center >