Viewing 5 replies - 1 through 5 (of 5 total)
  • Hi there!

    Which method are you trying?

    Thread Starter kbflymry

    (@kbflymry)

    Hi James, the redirect method.

    Thanks for your reply!

    Plugin Support Truman

    (@tdorn)

    Hi there,

    Can you paste the code that you are using so that we can look over it here? You would have probably had to make some tweaks to what is on that page, so please let us know!

    Thread Starter kbflymry

    (@kbflymry)

    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;
    }

    Hi there @kbflymry

    Thanks for reaching out, and my apologies for the delayed response.

    This particular workaround is only compatible with our legacy calendar views and doesn’t work well with the updated calendar designs.

    You can explore using a third party membership or content access restriction plugins achieve this.

    Here’s where you can get some more information on how membership plugins work with The Events Calendar: https://theeventscalendar.com/knowledgebase/guide/the-events-calendar-membership-plugins/

    Kind regards,

    Marho

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Members Only Calendar’ is closed to new replies.