• I’m trying to remove the capability of users other than the admin (ID number 1) to add a page, I know that there are plugins which you can edit the role but in my case I need the users to be ‘Administrator’ role but I need to remove some capabilities. I have the following code:

    function modify_capabilities()
    {
    	global $userdata;
    	get_currentuserinfo();
      $userdata->ID != 1 ->remove_cap('publish_pages');
    
      // for posts it should be:
      // $editor_role->remove_cap('publish_posts');
    
      // to add capabilities use add_cap()
    }
    
    add_action('admin_init','modify_capabilities');

    but I’m not sure why it isn’t working. Please help fix the code, thanks

    Note: The reason why it needs to be Administrator role because a specific plugin I use only displays reports to ‘Administrator’.

    [No bumping, thank you.]

Viewing 3 replies - 1 through 3 (of 3 total)
  • I would take a look at the Role Scoper plugin.

    Thread Starter rize

    (@rize)

    From what I read of Role Scoper, it’s per role.. I need it per Username/user..

    remove_cap() requires a role to be passed.

    One solution, use the Role Scoper or members plugin to create a role of Special Admin. Assign that role all the admin responsibilities. Next, adjust the capabilities for the admin role as needed. Give the Special Admin role to user 1 and the admin role to the other users.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Remove publishing capability from user IDs’ is closed to new replies.