#5367
Vladimir
Keymaster

Hi,

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.