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:

if (class_exists('YITH_Stripe_Connect')){


if (!function_exists('yith_wcsc_account_menu_item_custom')){
function yith_wcsc_account_menu_item_custom($items){

$available_role = 'yith_vendor';

$user_id = get_current_user_id();
if ($user_id){
$user = get_userdata( $user_id );
if ($user){
$user_roles = $user->roles;
if ($user_roles){
if ( !in_array( $available_role, $user_roles, true ) ) {
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(){

$available_role = 'yith_vendor';

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

add_action('init', 'yith_wcsc_disable_stripe_connect_account_page');
}
}
You can apply this for other user roles. You can change the user role in the variable: $available_role.
 
For example (for shop manager users only): $available_role = 'shop_manager';
Was this article helpful?
0 out of 0 found this helpful

Back to Help Center >