WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I just created a custom post type named Catalog. Where authors can create as many entries they need. But I need to restrict/deny access to all admin parts: Posts, Profile, Media or other admin parts except their Catalog entries.

Do I need to compare against $_SERVER['REQUEST_URI'] or theres a better way?

Thanks in advance.

share|improve this question
There should be a class from MikeSchnikel, that's already a core proposal, around the web that unsets (not only display: none;) all not needed menu items (and pages). Alternative approach, but not bad :) – kaiser Apr 1 '11 at 3:57
up vote 2 down vote accepted

This is more difficult than it needs to be it seems.

To code it without using a plugin I would suggest using global $menu and global $submenu as an array and unset them based on user role or user name. It might get more difficult if you want to define user role permissions outside default values. http://codex.wordpress.org/Roles_and_Capabilities

You can find the values in wp-admin/menu.php , you must look in here. Or browse them here http://core.trac.wordpress.org/browser/branches/3.1/wp-admin/menu.php

For example if you want to unset a menu in a function it would be something along the lines of:

function remove_menu() {
global $menu;
//remove post top level menu for editor role
if current_user_can('editor'){
unset($menu[5]); }
add_action('admin_head', 'remove_menu');
// ($menu[5]) is the "Posts" menu

You can see a much more detailed example here http://hungred.com/how-to/remove-wordpress-admin-menu-affecting-wordpress-core-system/

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.