im trying to redirect users on specific categry with this hook:
// Show app-data posts only to app users
function user_redirect()
{
if ( is_category( 'app-data' ) ) {
$url = site_url();
wp_redirect( $url );
exit();
}
}
add_action( 'the_post', 'user_redirect' );
But its not working and i dont know why. it redirect if the user if browsing the category. i want to redirect if the user is browsing the category or a post of that category