Hi @tdorn , I’m trying to redirect this page – https://mrjdev.wpengine.com/events/- (this is the Events Calendar landing page) – to https://mrjdev.wpengine.com/login/ if not logged in, but I still get the white screen of death when logged out users load https://mrjdev.wpengine.com/events/.
This is the code I’m using:
add_filter( 'tribe_events_pre_get_posts', 'redirect_from_events' );
function redirect_from_events( $query ) {
if ( is_user_logged_in() )
return;
if ( ! $query->is_main_query() || ! $query->get( 'eventDisplay' ) )
return;
// Look for a page with a slug of "login".
$target_page = get_posts( [
'post_type' => 'page',
'name' => 'login'
] );
// Use the target page URL if found, else use the home page URL.
if ( empty( $target_page ) ) {
$url = get_home_url();
} else {
$target_page = current( $target_page );
$url = get_permalink( $target_page->ID );
}
// Redirect!
wp_safe_redirect( $url );
exit;
}