0

I have created a custom post type.

Each author is attributed to a editor group when her/his account is created. This is save on the author's user meta

I created two roles with administrator capabilities, one for each editor group.

I want to allow (or deny) the editors to edit the posts based on their role and on the author's user meta.

Where can I begin?

1 Answer 1

0

I manage to filter the posts, this seems to be enough for this project

function remove_notallowed_authors( $query ) {
    $user = wp_get_current_user();

    if ( in_array( 'editor_group_role', (array) $user->roles ) ) {
        $user_ids = get_users( [
            'role'   => 'user_role_that_posted',
            'fields' => 'ID'
        ] );

        $query->set( 'author__in', $user_ids );
    }
    
}
add_action( 'pre_get_posts', 'remove_notallowed_authors' );

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.