I have this code to disable/remove the payments tab from the WooCommerce settings tab, however, the users can still directly access the payments settings / payment methods using the direct url like wp-admin/admin.php?page=wc-settings&tab=checkout
add_filter( 'woocommerce_settings_tabs_array', 'wd_remove_woocommerce_payment_tab', 200, 1 );
function wd_remove_woocommerce_payment_tab( $tabs_array ) {
$wd_allowed_users = array("asd", "asd", "asd");
$wd_user = wp_get_current_user();
if ( in_array(strtolower($wd_user->user_login), $wd_allowed_users)){
unset( $tabs_array['checkout'] );
}
return $tabs_array;
}
2
Answers
I have used the following code, similar to what LoicTheAztec have suggested above and that resolved it. Pasting it here, just in case someone needs that.
You can try the following, that will redirect the non-allowed users to WooCommerce Admin General settings, when trying to access WooCommerce Admin Payments page:
Code goes in functions.php file of your child theme (or in a plugin).