WP-Admin: Only allow users with a 'manager' capability to view Autoship Cloud pages

Only allow users with a 'manage_woocommerce' capability to see Autoship pages within WP-Admin > Autoship Cloud

Important: Always test customizations to your site on a staging environment before making changes to your live / production site.  If you are not experienced with testing changes on a staging site, here is a good article to review.

/**
* allow shop managers & Admins access to the main Autoship Menu option.
* @param string $capability The capability required for this menu to be displayed to the user.
* @return string The filtered capability
*/
function xx_autoship_for_managers_only( $capability ){
  return 'manage_woocommerce';
}
add_filter('autoship_cloud_main_page_security', 'xx_autoship_for_managers_only', 10, 1);

/**
* allow shop managers & Admins access to the Autoship Pages.
* @param string $capability The capability required for this menu to be displayed to the user.
* @param string $slug The slug name for the menu
* @return string The filtered capability
*/
function xx_autoship_subpages_for_managers_only( $capability, $slug ){
  return 'manage_woocommerce';
}
add_filter( 'autoship_cloud_subpage_security', 'xx_autoship_subpages_for_managers_only', 10, 2);

Still need help? Contact Us Contact Us