In this post you'll find out how to make Yoast's Options tab, found within the WordPress admin area, available to the WooCommerce Shop_Manager role
This is something that we searched high and low for, on both Yoast’s website, the WooCommerce website and also the usual interweb Google searches too – they all drew a blank, so we decided to code a solution (well, a function!) for ourselves.
The Problem
On quite a few recent WooCommerce website builds that we have developed for our clients, we found the Shop Manager user role to be about the best solution in order to give shop owners a clear view of their inventory, orders, pages, products and other important info, without overcrowding the WordPress admin area with things that they won’t use on a day-to-day basis. However, Yoast’s settings are hidden to Shop Managers (gasp!) …enter Colab Digital!
The Solution
To give WooCommerce Shop Managers access to Yoast’s settings and options tab, we created a function that looks to see if the current user is a shop_manager, and the function simply unhides the tab. Yes, that simple, but yet so hard to find, and we decided to share this little nugget of wisdom because we are nice 😉 .
So without further ado, here’s the code to give the WooCommerce shop_manager role access to Yoast’s settings and options tab, add this code to your theme’s functions.php file – and you’re away (you can thank us later!):
//Yoast Settings Access for Shop Managers
function colab_shop_manager_yoast_access() {
$role = get_role( 'shop_manager' );
$role->add_cap( 'wpseo_manage_options', true );
}
add_action( 'init', 'colab_shop_manager_yoast_access', 11 );