How to restrict editing capability on specific page for specific user.

I have wordpress single installation website for a chain of stores.

the website shows all different store location, hours and etc. Basically each store has each page. I would like to make a specific user(such as a store manager of a store) can only access to his or her store page. How can I assign a certain user to edit only selected page but not other pages? Can I do the same thing for widget and other wordpress area?

I have played user role editor, but it gives only access level. it shows all the page or none.

Let me know if you have an idea.

  • Aicee Taguilaso
    • WordPress Warrior

    Hi Yosuke!

    Hope you’re having a great day! :slight_smile:

    You can add this code to your functions.php (if you have a child theme, better add it to your child’s functions.php):

    $user = new WP_User( $user_id );
    $user->add_cap( 'edit_pages' );
    $user->add_cap( 'edit_published_pages' );

    Just replace the ‘$user_id’ with the specific user’s id from the URL when you edit a specific user from the admin dashboard page.

    Here is a full list of WP capabilities: http://codex.wordpress.org/Roles_and_Capabilities

    Another reference for you: http://www.wpmayor.com/roles-capabilities-wordpress/

    You can also try this plugin: https://wordpress.org/plugins/user-role-editor/

    Let me know if that helps!

    Thanks! :slight_smile:

    Regards,

    Aicee

  • Yosuke
    • Design Lord, Child of Thor

    Hello @aicee,

    Thank you for your response and other references! That’s great!

    I think I understand how to add capability to specific user.

    $user = new WP_User( 2 );

    $user->add_cap( ‘edit_pages’ );

    $user->add_cap( ‘edit_published_pages’ );

    This add user id 2 can edit pages and published pages right?

    How do I allow specific page to this user? say, if I want let user #2 to edit only page id 2504 and 2510 ?

    This user cannot edit other pages. Ideally, I do not want to show other pages(pages this user doesn’t have control) in admin dashboard. But I don’t know if possible.

    Let me know.

    Thank you in advance.

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.