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.

  • 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

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/

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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