Change WordPress user roles and capabilities › Forums › Give user access to plugin – how to › Need to give a user access to specific page on WooCommerce › Reply To: Need to give a user access to specific page on WooCommerce
07/12/2019 at 08:50
#6179
Vladimir
Keymaster
Hi,
Setup this code as Must Use plugin or add it to your active Theme. It leaves only 2 tabs at WC->Settings page: General and Payments. And replace ‘orders_manager’ role ID with your own one.
In order to leave Payments only, you need apply more programming efforts, replace link of WC-Settings menu from default one to
wp-admin/admin.php?page=wc-settings&tab=checkout
add_filter('woocommerce_settings_tabs_array', 'change_wc_settings_tabs', 30);
function change_wc_settings_tabs( $pages ) {
$user = wp_get_current_user();
if ( in_array( 'orders_manager', $user->roles ) ) {
//unset( $pages['general']); // General
unset( $pages['products']); // Products
unset( $pages['tax']); // Tax
//unset( $pages['checkout']); // Payments
unset( $pages['account']); // Accounts & Privacy
unset( $pages['email']); // Emails
unset( $pages['advanced']); // Advanced
}
return $pages;
}