It appears that the "Stripe Gateway" plugin you’re using doesn’t offer the ability to selectively allow or deny use by role. Testing a few of these today, I haven’t found one that does. So the (great) User Role Editor plugin may not be able to help you accomplish this task. But don’t despair! There are other ways 🙂
If I understand correctly, you want to hide the Stripe settings from one ore more roles/users (so the live API keys are secure), right? It’s easiest to remove it from a role.
Actually, there are two steps involved. One is to hide the "Stripe Gateway" menu that you mention, naturally, but Stripe settings are also found under the WooCommerce Payment tab. We would need need to hide that tab for the user/role also.
There may be a more elegant solution but I can offer a suggestion that accomplished this task.
To hide the unwanted ‘Stripe" menu, install the Adminimize plugin and activate.
Then Dashboard – Settings – Adminimize – Menu Options
The screen that appears will show in table format on the left, all the Dashboard menus and this should include your "Stripe Gateway". On the right is a list of roles .
Find your unwanted "Stripe Gateway" menu in the Adminimize table and for the Shop Manager role on the right of the table tick the "Deactivate for Shop Manager" settings checkbox.
Remember to scroll down and click the "Update Options" button to save the plugin settings.
Hopefully that menu has now disappeared for that role in the Dashboard.
Now I couldn’t find the exact Stripe plugin that you’re using but illustrate with another to produce the screencap here illustrating what I’ve written (link to screencap). Adminimize – hiding a menu from Shop manager role
The second step is to remove the Payment tab for the WooCommerce Shop Managers role. This has been answered here. Using the code from that post, add the following to your child theme’s functions.php (if you’re using a child theme).
add_filter( 'woocommerce_settings_tabs_array', 'remove_woocommerce_setting_tabs', 200, 1 );
function remove_woocommerce_setting_tabs( $tabs ) {
// Declare the tabs we want to hide
$tabs_to_hide = array(
'Payments',
);
// Get the current user
$user = wp_get_current_user();
// Check if user is a shop-manager
if ( isset( $user->roles[0] ) && $user->roles[0] == 'shop_manager' ) {
// Remove the tabs we want to hide
$tabs = array_diff($tabs, $tabs_to_hide);
}
return $tabs;
}
2
Answers
SO I have created this :
It appears that the "Stripe Gateway" plugin you’re using doesn’t offer the ability to selectively allow or deny use by role. Testing a few of these today, I haven’t found one that does. So the (great) User Role Editor plugin may not be able to help you accomplish this task. But don’t despair! There are other ways 🙂
If I understand correctly, you want to hide the Stripe settings from one ore more roles/users (so the live API keys are secure), right? It’s easiest to remove it from a role.
Actually, there are two steps involved. One is to hide the "Stripe Gateway" menu that you mention, naturally, but Stripe settings are also found under the WooCommerce Payment tab. We would need need to hide that tab for the user/role also.
There may be a more elegant solution but I can offer a suggestion that accomplished this task.
Hopefully that menu has now disappeared for that role in the Dashboard.
Now I couldn’t find the exact Stripe plugin that you’re using but illustrate with another to produce the screencap here illustrating what I’ve written (link to screencap).
Adminimize – hiding a menu from Shop manager role
The second step is to remove the Payment tab for the WooCommerce Shop Managers role. This has been answered here. Using the code from that post, add the following to your child theme’s functions.php (if you’re using a child theme).
The result is illustrated here (link to screencap).
Hiding a tab in WooCommerce
I’m sure there are more experienced WooCommerce people who can provide a better answer but I hope this helps.