{"id":957989,"date":"2015-04-24T04:13:55","date_gmt":"2015-04-24T11:13:55","guid":{"rendered":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/password-protecting-the-calendar\/"},"modified":"2015-04-28T10:18:39","modified_gmt":"2015-04-28T17:18:39","slug":"password-protecting-the-calendar","status":"closed","type":"topic","link":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/password-protecting-the-calendar\/","title":{"rendered":"Password Protecting the Calendar"},"content":{"rendered":"<p>Hi,<br \/>\nI&#8217;m using this on a multisite install where the theme gives you the option to protect all of the content on the site or not by using the advanced custom fields plugin from Elliot Condon. It is as simple as if this site should be private a radio button is selected and then in my theme all content is hidden if it is selected. This works perfectly for everything except for the events calendar which always displays no matter what.<\/p>\n<p>I thought maybe it was just a case of not modifying the right template, but nothing seems to work. I&#8217;ve even tried selecting my own templates from within the events settings and the calendar still displays even when it shouldn&#8217;t. IS this not possible or am I missing something.<\/p>\n<p>Here is the calendar working: http:\/\/telford-webdesign.co.uk\/events\/<br \/>\nHere is a different site where it should not display because you are not logged in: http:\/\/richmond.telford-webdesign.co.uk\/events\/<\/p>\n<p>(This domain is my staging area for myechef.co.uk &#8211; which is registered &#8211; and once this works will be pushed to that domian)<\/p>\n<p>I have this set up to use the default events template, which I copied from \/plugins\/the-events-calendar\/views\/default-template.php and copied to \/themes\/my-theme\/tribe-events\/views\/default-template.php<\/p>\n<p>My code is:<\/p>\n<p>&lt;?php<br \/>\n\/**<br \/>\n * Default Events Template<br \/>\n * This file is the basic wrapper template for all the views if &#8216;Default Events Template&#8217;<br \/>\n * is selected in Events -&gt; Settings -&gt; Template -&gt; Events Template.<br \/>\n *<br \/>\n * Override this template in your own theme by creating a file at [your-theme]\/tribe-events\/default-template.php<br \/>\n *<br \/>\n * @package TribeEventsCalendar<br \/>\n *<br \/>\n *\/<\/p>\n<p>\/\/ Get the value of the radio button<br \/>\n$protected = get_field(&#8216;protected&#8217;, &#8216;option&#8217;);<br \/>\n\/\/ Make sure we know the blog ID to stop users from other sub domains accessing<br \/>\nglobal $blog_id;<\/p>\n<p>if ( ! defined( &#8216;ABSPATH&#8217; ) ) {<br \/>\n\tdie( &#8216;-1&#8217; );<br \/>\n}<\/p>\n<p>get_header(); ?&gt;<\/p>\n<p>&lt;div id=&#8221;tribe-events-pg-template&#8221;&gt;<\/p>\n<p>\t&lt;?php tribe_events_before_html(); ?&gt;<\/p>\n<p>\t&lt;?php<br \/>\n\t\/\/&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br \/>\n\t\/\/&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br \/>\n\t\/\/ Check to see if this should be protected first<br \/>\n\t\/\/ echo &#8220;test &#8221; . $protected;<\/p>\n<p>\tif ( $protected == &#8216;Yes&#8217;) :<br \/>\n\t\t\/\/&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br \/>\n\t\t\/\/&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br \/>\n\t\t\/\/ If so, check if someone is logged in and they have permissions for this blog<br \/>\n\t\tif ( is_user_logged_in() &amp;&amp; current_user_can_for_blog( $blog_id, &#8220;read&#8221; ) ) : <\/p>\n<p>\t\t?&gt;<\/p>\n<p>\t\t\t&lt;?php tribe_get_view(); ?&gt;<\/p>\n<p>\t\t&lt;?php<br \/>\n\t\t\/\/&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br \/>\n\t\t\/\/&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br \/>\n\t\t\/\/ If not logged in show error text from Options page in admin<br \/>\n\t\telse : ?&gt;<\/p>\n<p>\t\t\t&lt;div class=&#8221;grid__item palm-one-whole lap-one-whole&#8221;&gt;<br \/>\n\t\t\t\t&lt;?php<br \/>\n\t\t\t\t$not_logged_in = get_field(&#8216;not_logged_in&#8217;, &#8216;option&#8217;);<br \/>\n\t\t\t\techo $not_logged_in;<br \/>\n\t\t\t\t?&gt;<br \/>\n\t\t\t&lt;\/div&gt;<\/p>\n<p>\t\t&lt;?php<br \/>\n\t\tendif;<br \/>\n\t\t\/\/ Ends if logged in and you have permission<br \/>\n\t\t\/\/&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br \/>\n\t\t\/\/&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<\/p>\n<p>\t\/\/&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br \/>\n\t\/\/&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br \/>\n\t\/\/ Else the site is not protected so just show the standard content<br \/>\n\telse : ?&gt;<\/p>\n<p>\t\t&lt;?php tribe_get_view(); ?&gt;<\/p>\n<p>\t\t&lt;?php<br \/>\n\tendif;<br \/>\n\t\/\/ Ends if the site should be protected or not<br \/>\n\t\/\/&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br \/>\n\t\/\/&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br \/>\n\t?&gt;<\/p>\n<p>\t&lt;?php tribe_events_after_html(); ?&gt;<\/p>\n<p>&lt;\/div&gt; &lt;!&#8211; #tribe-events-pg-template &#8211;&gt;<\/p>\n<p>&lt;?php get_footer(); ?&gt;<\/p>\n<p>I have also tried adding this if logged in code to \/themes\/my-theme\/tribe-events\/views\/month.php as well, but that didn&#8217;t work either. I know the code to check for the custom field is working because its been copied and pasted from other templates in my theme which do work as excpected.<\/p>\n<p>Can you help? I&#8217;m at a loss as to why this always displays. I must still have the wrong template surely?<\/p>\n<p>Thanks<\/p>\n<p>Kirsty<\/p>\n","protected":false},"template":"","class_list":["post-957989","topic","type-topic","status-closed","hentry"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v25.2 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Password Protecting the Calendar -<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/password-protecting-the-calendar\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Password Protecting the Calendar -\" \/>\n<meta property=\"og:description\" content=\"Hi, I&#8217;m using this on a multisite install where the theme gives you the option to protect all of the content on the site or not by using the advanced custom fields plugin from Elliot Condon. It is as simple as if this site should be private a radio button is selected and then in [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/password-protecting-the-calendar\/\" \/>\n<meta property=\"article:modified_time\" content=\"2015-04-28T17:18:39+00:00\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/password-protecting-the-calendar\/\",\"url\":\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/password-protecting-the-calendar\/\",\"name\":\"Password Protecting the Calendar -\",\"isPartOf\":{\"@id\":\"https:\/\/theeventscalendar.com\/support\/#website\"},\"datePublished\":\"2015-04-24T11:13:55+00:00\",\"dateModified\":\"2015-04-28T17:18:39+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/password-protecting-the-calendar\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/password-protecting-the-calendar\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/password-protecting-the-calendar\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/theeventscalendar.com\/support\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Topics\",\"item\":\"https:\/\/theeventscalendar.com\/support\/topics\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Ticket Products\",\"item\":\"https:\/\/theeventscalendar.com\/support\/forums\/forum\/event-tickets\/\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"Event Tickets Plus\",\"item\":\"https:\/\/theeventscalendar.com\/support\/forums\/forum\/event-tickets\/event-tickets-plus\/\"},{\"@type\":\"ListItem\",\"position\":5,\"name\":\"Password Protecting the Calendar\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/theeventscalendar.com\/support\/#website\",\"url\":\"https:\/\/theeventscalendar.com\/support\/\",\"name\":\"\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/theeventscalendar.com\/support\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Password Protecting the Calendar -","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/password-protecting-the-calendar\/","og_locale":"en_US","og_type":"article","og_title":"Password Protecting the Calendar -","og_description":"Hi, I&#8217;m using this on a multisite install where the theme gives you the option to protect all of the content on the site or not by using the advanced custom fields plugin from Elliot Condon. It is as simple as if this site should be private a radio button is selected and then in [&hellip;]","og_url":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/password-protecting-the-calendar\/","article_modified_time":"2015-04-28T17:18:39+00:00","twitter_card":"summary_large_image","twitter_misc":{"Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/password-protecting-the-calendar\/","url":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/password-protecting-the-calendar\/","name":"Password Protecting the Calendar -","isPartOf":{"@id":"https:\/\/theeventscalendar.com\/support\/#website"},"datePublished":"2015-04-24T11:13:55+00:00","dateModified":"2015-04-28T17:18:39+00:00","breadcrumb":{"@id":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/password-protecting-the-calendar\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/theeventscalendar.com\/support\/forums\/topic\/password-protecting-the-calendar\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/password-protecting-the-calendar\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/theeventscalendar.com\/support\/"},{"@type":"ListItem","position":2,"name":"Topics","item":"https:\/\/theeventscalendar.com\/support\/topics\/"},{"@type":"ListItem","position":3,"name":"Ticket Products","item":"https:\/\/theeventscalendar.com\/support\/forums\/forum\/event-tickets\/"},{"@type":"ListItem","position":4,"name":"Event Tickets Plus","item":"https:\/\/theeventscalendar.com\/support\/forums\/forum\/event-tickets\/event-tickets-plus\/"},{"@type":"ListItem","position":5,"name":"Password Protecting the Calendar"}]},{"@type":"WebSite","@id":"https:\/\/theeventscalendar.com\/support\/#website","url":"https:\/\/theeventscalendar.com\/support\/","name":"","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/theeventscalendar.com\/support\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"}]}},"_links":{"self":[{"href":"https:\/\/theeventscalendar.com\/support\/wp-json\/wp\/v2\/topic\/957989","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/theeventscalendar.com\/support\/wp-json\/wp\/v2\/topic"}],"about":[{"href":"https:\/\/theeventscalendar.com\/support\/wp-json\/wp\/v2\/types\/topic"}],"version-history":[{"count":1,"href":"https:\/\/theeventscalendar.com\/support\/wp-json\/wp\/v2\/topic\/957989\/revisions"}],"predecessor-version":[{"id":958132,"href":"https:\/\/theeventscalendar.com\/support\/wp-json\/wp\/v2\/topic\/957989\/revisions\/958132"}],"wp:attachment":[{"href":"https:\/\/theeventscalendar.com\/support\/wp-json\/wp\/v2\/media?parent=957989"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}