Remove multiple options for one user role only

Hello

I’m looking to hide most options from within the MainWP dashboard for one particular role only.

Role: mainwp_limitedadministrator

I followed the instructions on the below URL, but have ran into some issues with it working for one role only - managed to get it working without the IF role function.

Could someone please help me with coding the role and hiding the below options?

  • Updates
  • Posts
  • Pages
  • Themes
  • Plugins
  • Users
  • Settings
  • Extensions
  • Status

Only leaving “Sites” for them to have access to.

Thank you in advance.

Hi Nathan,

Can you please tell me the Role name so I can update the code snippet and test it?

Hi Bogdan

I did list the role name above “mainwp_limitedadministrator”.

It’s a custom WP role that I created for limited access to the Wordpress admin, but I am sure you can test with any non-administrator role for the same?

Regards

Hey Bogdan, did you have any ideas? Thanks heaps

Hi Nathan,

Can you please try with this code:

add_filter( 'mainwp_main_menu', 'mycustom_mainwp_main_menu', 10, 1 );
function mycustom_mainwp_main_menu( $left_menus ) {
	if ( current_user_can( 'mainwp_limitedadministrator' ) ) {
		$left_menus = array();
		$left_menus['mainwp_tab'] = array( 
			array(
				'Sites',
				'managesites',
				'admin.php?page=managesites'					
			)
		);
	}	
	return $left_menus;
}
1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.