WordPress.org

Ready to get started?Download WordPress

Forums

Remove publishing capability from user IDs (4 posts)

  1. rize
    Member
    Posted 2 years ago #

    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.]

  2. NateJacobs
    Member
    Posted 2 years ago #

    I would take a look at the Role Scoper plugin.

  3. rize
    Member
    Posted 2 years ago #

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

  4. NateJacobs
    Member
    Posted 2 years ago #

    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.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.