Hi there!
Will fix in next update.
Thanks!
Thread Starter
N.g
(@loralora)
Hello,
- Thanks for the quick response! – the “Messages” tab has appeared in the sidebar in MultivendorX – thank you.
2. Sorry, I didn’t explain correctly – I meant to hide the messages tab if you select “Show on WooCommerce account page” in “General” – Message Locations.
i.e., if the following is selected in Role Restrictions:
- No one can message each other.
- But allow: From “user role” To “user role.”
Then is there a way to disable the “Show on WooCommerce account page” tab for all other user roles?
Users think they’ve been blocked or restricted, when they shouldn’t see this functionality at all.
Perhaps you have some code that could help?
Thank you again.
Hi there!
Something like this should work to remove My Account tab:
add_filter( 'woocommerce_account_menu_items', function( $items ) {
if ( ! function_exists( 'Better_Messages' ) ) {
return $items;
}
$user_id = get_current_user_id();
if ( $user_id <= 0 ) {
return $items;
}
// Administrators always see the tab.
if ( user_can( $user_id, 'manage_options' ) ) {
return $items;
}
$settings = Better_Messages()->settings;
// Only act in "No one can message, but allow from X to Y" mode.
if ( ( $settings['restrictRoleType'] ?? '' ) !== 'disallow' ) {
return $items;
}
// If the user has any allowed-target roles, keep the tab visible.
if ( ! empty( Better_Messages()->functions->get_restrict_to_roles( $user_id ) ) ) {
return $items;
}
// BM uses one of two menu keys depending on Settings -> General -> Message Locations:
// - 'better-messages' when the side-tab integration is enabled
// - the wooCommerceMessagesSlug value when BM is the primary "chat page"
$keys_to_strip = array( 'better-messages' );
$slug = $settings['wooCommerceMessagesSlug'] ?? '';
if ( $slug !== '' ) {
$keys_to_strip[] = $slug;
}
foreach ( $keys_to_strip as $key ) {
unset( $items[ $key ] );
}
return $items;
}, 30 );