我设法过滤帖子,这对这个项目来说似乎已经足够了
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\' );