• Resolved GhostPool

    (@ghostpool)


    I’m trying to redirect logged out users from the Events calendar page to the home page, but it doesn’t work. This works for other pages including the single event posts. However on the Events calendar page the page is not redirected it just shows a blank white page.

    function ghostpool_restrict_logged_out_user_access() {
    			
    	if ( is_user_logged_in() ) {
    		return;
    	}
    
    	if ( is_post_type_archive( 'tribe_events' ) ) {
    	     wp_redirect( home_url( '/' ) );
    	}
    
    }
    add_action( 'template_redirect', 'ghostpool_restrict_logged_out_user_access' );

    I’ve tested this with all other plugins disabled, using the default Twenty Twenty-One theme, with high and low priorities for the action, and the issue still occurs.

    • This topic was modified 3 years ago by GhostPool.
Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Support Deblyn Prado

    (@deblynprado)

    Hello @ghostpool!
    How’re you doing?

    The Post Type tribe_events that you’re using is correct.
    Instead is_post_type_archive() try to use get_post_type() and see if it works better

    Cheers,

    Thread Starter GhostPool

    (@ghostpool)

    Thanks for the response.

    It’s no so much the conditional statement that’s the issue, it’s the use of wp_redirect on the Events archive page that seems to be the problem.

    The only workaround I could find was to not use a redirect and use conditionals on the Events list template itself to load alternative content for logged out users.

    Plugin Support Chika Ibeneme

    (@chikaibeneme)

    Hi @ghostpool !

    We’re glad that you were able to find a workaround!

    There hasn’t been any activity on this post, therefore, we’ll be closing it! Please feel free to open a new thread if any other questions come up and we’d be happy to help. ??

    Thank you,
    Chika

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Redirect from Events Calendar page not working’ is closed to new replies.