Change WordPress user roles and capabilities Forums Restrict or Permit access inside WordPress – how to How to allow a user role to see and edit others posts?

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
  • #5360


    I have a CPT ‘x’.

    For the user group with role A, I want it NOT be possible see/edit others post (X).

    For the user group with role B, I want it be possible see/edit others post (X) where the owner have role B (same role) – posts where owner have role A not could be displayed here.



    1) role A: Edit restrictions add-on has “Own data only” option. It hides posts created by other authors from the current user at wp-admin posts list page.

    2) role B: There is no criterion for edit restrictions by the role of authors. It’s possible to use tags or categories though. This post may give a starting point.



    thank you for your response. But this not work for me. I have a group of people that need to access the posts by role. Are the employees of a company. But, into this site is possible that exists posts created by other persons (out of company) that uses another role profile.

    So, if your plugin no have this feature, may be a good idea to do because groups os users could share each other some posts, as in my case.

    If you have another suggestion of how to do it, please, share.



    try this code:

    add_filter('ure_post_edit_access_authors_list', 'ure_restrict_authors_list');
    function ure_restrict_authors_list($authors) {
        $role = 'author';
        $user = wp_get_current_user();    
        if (!in_array($role, $user->roles)) {
            return $authors;
        $args = array(
            'role' => $role
        $wp_user_search = new WP_User_Query( $args );
        $users = $wp_user_search->get_results();
        $ids = array();
        foreach( $users as $user ) {
            $ids[] = $user->ID;
        $ids_str = implode( ',', $ids );
        $authors = URE_Utils::concat_with_comma( $authors, $ids_str );
        return $authors;

    Replace ‘author’ role with your role id, like ‘role_b’. Do not forget to add ‘edit_others_posts’ capability to role_b role in order it can edit posts from other authors. Only posts from users with role_b role will be available for editing for any user with role_b role with this code applied.


    Thank you Vladimir! Works fine!

Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.