WP-Admin: Allow Limited Admin Access to Different User Roles

In this example, the wordpress user role of "contributor" is enabled to view the Scheduled Orders screen in WP-Admin > Autoship Cloud > Scheduled Orders 

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.

/**
* 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 sales team with a Contributor role to see Autoship Cloud > Scheduled Orders screen
    return 'scheduled-orders' == $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 sales team with a Contributor role to see Autoship Cloud > Scheduled Orders 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