autoship_cloud_subpage_security

can be used to adjust who has rights to see the supplied subpage content. The filter takes the current capability needed for a user to see the Autoship Cloud subpage page and the current menu_slug . By Default the Administrator capability is required.

IMPORTANT NOTE Due to the structure of the plugin pages and subpages if a non-administrator needs to be given rights to a subpage ( i.e. a user with non-admin rights but edit_post capabilities like a contributor) the capability should be set at the 'autoship_cloud_main_page_security' filter and the 'autoship_cloud_subpage_security' filter for that menu_slug

Example

/**
* Adjusts the Security for the Autoship Sub Pages
* @link https://codex.wordpress.org/Roles_and_Capabilities#Capability_vs._Role_Table
*
* @param string $capability The current required cap.
* @param string $menu_slug The Sub Menu Page.
* @return string $capability The filtered cap.
*/
function xx_adjust_autoship_cloud_subpage_security( $capability, $menu_slug ){

  // Allow users with a Contributor role to see Autoship Cloud > Customers screen
  return ( 'customers' == $menu_slug || 'autoship' == $menu_slug ) ? 'edit_posts' : $capability;

}
add_filter('autoship_cloud_subpage_security', 'xx_adjust_autoship_cloud_subpage_security', 10, 2 );

/**
* Adjusts the Security for the Autoship Main Menu Page
* @link https://codex.wordpress.org/Roles_and_Capabilities#Capability_vs._Role_Table
*
* @param string $capability The current required cap.
* @return string $capability The filtered cap.
*/
function xx_adjust_autoship_cloud_main_page_security( $capability ){
  
  // Allow users with a Contributor role to see Autoship Cloud > Customers screen
  return 'edit_posts';

}
add_filter('autoship_cloud_main_page_security','xx_adjust_autoship_cloud_main_page_security', 10, 1);

Still need help? Contact Us Contact Us