Remove Posts Menu from Admin

While the content manager has the edit_posts capability so he can edit media items, this also exposes the posts menu. I don’t want the content manager to handle normal posts, so I decided to hide the menu item from the admin interface. It will still be possible to go to the URL manually and edit posts, but removing the item from the menu reduces the chance of user error.

The point is to reduce the number of options in the menu so the user isn’t intimidated. Really preventing the user from editing posts isn’t such an important issue for my use.

The article at sixrevisions was used to figure out what code to include. I determine which role the user holds by checking his capabilities. In my setup, only the content manager and admin has edit_sermons, but only the admin has update_core. Thus being having edit_sermons but not update_core makes the user a content manager.

function mbpc_remove_menu_items() {
	if ( current_user_can( 'edit_sermons' ) && !current_user_can( 'update_core') ) {

		global $menu;
		$restricted = array(__('Posts'));
		end ($menu);
		while (prev($menu)){
			$value = explode(' ',$menu[key($menu)][0]);
			if(in_array($value[0] != NULL?$value[0]:"" , $restricted)) {

add_action('admin_menu', 'mbpc_remove_menu_items');

Now when logged in as a content manager, the Posts menu can no longer be seen. Less clutter, less confusion.


2 thoughts on “Remove Posts Menu from Admin”

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s