Hi Marine,
You can try to use this code snippet that uses “is_category” condition and adjust as you want:
add_action( 'template_redirect', function() {
// Redirect users from specific page
// when user doesn't have particular role
$user = wp_get_current_user();
if ( is_category('your-category') && ( ! is_user_logged_in() || ( ! empty($user) && in_array( 'author', (array) $user->roles ) ) ) ) {
$redirect = 'https://your-domain.com/wp-login.php'; // Change this to the correct URL
wp_redirect( $redirect );
exit;
}
} );
To use it, you need to insert the code at the end of your theme’s functions.php file or install this plugin: https://www.ads-software.com/plugins/code-snippets/ and add it there.
Hopefully, that helps.