How to Password Protect Simple Calendar Pages

Simple Calendar – Google Calendar provides an easy way to add Google Calendar events to your WordPress site. You might want to make the calendar page private to everyone and only grant access to those with a password.

However, even after you have protected the calendar page, you will find it still accessible to the public. This happens because the WordPress built-in function is applied to the page content by default, while the Simple Calendar uses a shortcode to load its dynamic content.

That said, you can password protect the calendar pages by following the 3 simple steps below.

Requirements:

Step 1: Once activating our plugins, navigate to Password Protect WordPress >> Settings from your admin dashboard.

Then select “Calendars” from the Post Type Protection dropdown list.

Step 2: Password protect the calendar page.

Simply hover over the page title and then click on the “Protect” button to lock its content immediately.

Step 3: Add the following code snippet to your (child) theme’s functions.php file.

add_action('simcal_calendar_html_before', 'ppwp_maybe_render_password_form', 10);
function ppwp_maybe_render_password_form()
{
	if (post_password_required()) {
		echo get_the_password_form();
		exit();
	}
}

The password form should display in the protected content as normal.

Lasted updated on March 16, 2021