Allow WordPress User Roles to Edit Posts in Single Category
A PublishPress user asked us this question:
Can I set up my WordPress site so users from “Department A” can only create and edit posts in “Category A”? Then we’d like to do the same thing for other departments.
Yes, that is possible with the PublishPress plugins and I’m going to show you how it’s done:
Step #1. Create the Roles
First, we’ll need to install the Capability Manager Enhanced plugin.
- Go to Users > Capabilities.
- Choose “Subscriber” under “Select Role to View / Edit”.
- Click “Load”.
- Enter “Department A” into the “Copy Subscriber Role” box.
- Click “Copy”.
You will now have a new role called “Department A”. You can now repeat this process to create “Department B” and “Department C” roles. You’ll be able to see these new roles in the “Select Role to View / Edit” dropdown:
Step #2. Add the Users to Roles
Now you can go to your “Users” area and add users to these different roles. I’ve added one user to each of my three new roles:
Step #3. Create the Categories
The next step requires installing the PressPermit Pro plugin.
After installing the PressPermit Pro plugin, go to Posts > Categories.
Create a new category for “Department A”:
- Click “Edit” for the “Department A” category.
- At the bottom of the screen, check the box “enable custom permissions for Categories”.
- Click “Update”.
When the screen refreshes you will see new options:
- Post Reading Exceptions: Control who can read posts in this category.
- Post Editing Exceptions: Control who can edit posts in this category.
- Post Revision Exceptions: Control who can create revisions for posts in this category.
- Post Category Assignment Exceptions: Control who can add posts to this category.
So you can customize permissions for this category in multiple ways. We’re going to use the example of “Post Editing Exceptions”. This will control who can edit posts that have this category:
In this example, we will deny editing permissions to everyone except “Department A”.
Repeat this process by creating categoies for Department B and Department C users. Make sure to set the correct permissions using the “Post Editing Exceptions” area.
Step #4. Test the user accounts
At this point, I would highly recommend testing the user accounts to make sure their permissions are accurate.
First, let’s create a test post:
- Create a Post.
- Add the “Departement A” category to your new Post:
Now we’re going to login using one of the accounts that we want to restrict.
If you’re using dummy users, you can reset their passwords. If you’re testing with real users, the User Switching plugin is very helpful.
In this example, the Department A users will only be able to see the “Posts” menu link and the Posts that have the “Department A” category. They will not see the Pages for any other department.
Repeat this test for your other departments. When you’re finished, you should now have a site with user in different roles can only post or edit content in the category that you choose.
In this tutorial we focused only on editing, but you can also customize the category permissions for reading, creating posts, and creating revisions. PressPermit Pro is a very powerful and flexible plugin.
More PressPermit Pro tutorials
- Restrict users to posting in one category
- Block users from posting in one category
- Allow user roles to edit a single page
- How to control user access to specific categories
- Allow multiple users to edit a single post
- Stop users from seeing posts from other authors
Get PressPermit Pro and more
The Pro versions of PublishPress plugins are packed with extra features to help you manage your content. Get a PublishPress membership today for full access: