Modern Tribe private calendar redirect – WordPress and PHP

I have a WordPress site with a front-facing public section and a private members area with events provided by The Events Calendar plug-in by Modern Tribe.

My problem is that while all of my other pages are private and locked down, the Events Calendar page is still accessible from the public side if you know the exact URL. A Google search listing for an event in the calendar clicks through to the private back-end including the menu. I’ve locked down the content so none of the menus take you anywhere, but just directing any user following a link like that to the private calendar framework and the interior private menu is just not cool.

So, basically I need a simple PHP redirect that forces any user that is not logged into the private section, to the home page of the public website instead.

I searched the Stack Exchange database and found something that meets my needs, but I just can’t get it to work.

Here’s the code sample that should work:

* Login Redirect for public users
add_action( ‘template_redirect’, ‘redirect_to_specific_page’ );

function redirect_to_specific_page() {

if ( is_page(‘events’) && ! is_user_logged_in() ) {

wp_redirect( ‘’, 301 );

I pasted this into the functions.php file and modified the site domain information to match where I need the redirect to go.

Modern Tribe’s calendar plug-in uses /events as the default and you can’t change it easily unless you access the PHP file in the plug-in directory, but I was wondering if I almost need a wildcard type of function after the events as a catch-all.

Does anyone know why this PHP code doesn’t work? From what I can see, any user who is not logged in and accesses /events should be pushed to the home page. But it’s not working…

Read more here:: Modern Tribe private calendar redirect – WordPress and PHP

Leave a Reply

Your email address will not be published. Required fields are marked *