I added a template_redirect
to my functions.php file, which redirects private staff members to a "Staff No Longer Available" page. However, my code only works when I am logged in. Am I missing something?
function redirect_private_staff() {
if ( is_singular( 'our_providers' ) && 'private' == get_post_status() ) {
wp_redirect( 'https://www.nystromcounseling.com/provider-profile-unavailable/', 301 );
exit;
};
}
add_action( 'template_redirect', 'redirect_private_staff' );