We currently have about 50 pages, each of which I want a user (eg, bob, rob, smith) to be able to edit only 1 page. For example, bob & smith each have their own page. I do not want bob to be able to edit smith's page. I want bob to ONLY be able to edit bob's page. I don't care if he can see other pages. Looking through the user roles, I don't see a way to currently to do this- I only see how to allow restrict access on a global scale.
Are their any plugins to help restrict edit access per user, or roles restricted to editing specific pages and I can just add 1 user per role? Or was there a way to do this with default settings I missed.
We currently have about 50 pages, each of which I want a user (eg, bob, rob, smith) to be able to edit only 1 page. For example, bob & smith each have their own page. I do not want bob to be able to edit smith's page. I want bob to ONLY be able to edit bob's page. I don't care if he can see other pages. Looking through the user roles, I don't see a way to currently to do this- I only see how to allow restrict access on a global scale.
Are their any plugins to help restrict edit access per user, or roles restricted to editing specific pages and I can just add 1 user per role? Or was there a way to do this with default settings I missed.
Share Improve this question asked Mar 26, 2012 at 16:16 zealeuszealeus 731 gold badge1 silver badge3 bronze badges 1- 1 Contributor role only enables editing of own posts. Or you could create a custom role. – Brad Dalton Commented Oct 23, 2014 at 13:20
4 Answers
Reset to default 0The Role Scoper plugin can enable this.
You can add this to your functions.php
file in your template to allow the user to edit pages that they have created and manage media. Just specify their $user_id
(i.e. 27):
function add_theme_caps() {
// to add capability to $user_id
$user = new WP_User( $user_id );
$user->add_cap( 'edit_pages' );
$user->add_cap( 'edit_published_pages' );
$user->add_cap( 'upload_files' );
}
add_action( 'admin_init', 'add_theme_caps' );
You can find a specific user's $user_id
from the URL when you edit a specific user from the Wordpress admin page.
See the full list of Wordpress capabilities.
If you'd rather modify the built in role contributor
to allow all users with the contributor
role to modify the pages they created:
function add_theme_caps() {
// to add capability to the role `contributor`
$role = get_role( 'contributor' );
$role->add_cap( 'edit_pages' );
$role->add_cap( 'edit_published_pages' );
$role->add_cap( 'upload_files' );
}
add_action( 'admin_init', 'add_theme_caps' );
Role Scope is very powerful, but I think it's overkill for this. If you set Bob and Smith to have the role of Author (one of the default roles), they'll only be able to edit their own posts.
You can also just edit the WP table. Seemed like phpAdmin was going to be a quicker way to go.
The table is
wp_usermeta
Search for the user_id, change the value for
wp_capabilities
and set it to something like
a:4:{s:11:"contributor";b:1;b:1;s:10:"edit_pages";b:1;s:20:"edit_published_pages";b:1;s:12:"upload_files";b:1;}
I found http://www.unserialize.me/ to be a help in making sure I had the serialization correct (and I expect there are other sites as well)