Viewing 2 replies - 1 through 2 (of 2 total)
  • Hi @kulpreets,

    Hopefully there’s a Knowledgebase article covering that up: https://theeventscalendar.com/knowledgebase/frontend-roles-and-permissions/

    Please check that out and let us know,
    Best,
    Nico

    Since this request keeps coming up (I’ve been trying to do this for days), I want to share here what this link offers in case it is exactly what you need. The link’s solution is EASY and it WORKS. It took less than 5 minutes to implement and test.

    RESTRICTING ACCESS TO CALENDAR AND EVENTS
    @nico’s link sends you to two snippets that allow you to restrict access to calendar content:

    1) Can’t view it on the site. The first snippet restricts users that are not logged in from accessing the display of virtually generated content (e.g., the main page) as well as of event details.

    2) Doesn’t appear in search results. The second snippet prevents your events from appearing in search results on your site if a user is not logged in.

    PRACTICAL EFFECTS
    I copied this snippet into my functions.php file, and here are the functional results:

    – Clicking on the main Events Page slug redirects to your designated advisory page (e.g., “This is restricted content”).
    – Shortcode content still displays (e.g., the embedded countdown clock for an event)
    – Clicking on shortcode links for more details redirects users that aren’t logged in to your advisory page.
    – Directly entering an event slug into the address bar also redirects users to your advisory page.

    Note: I chose not to restrict the search results because I wanted users to see all of our delightful events. I just modified my search results so dates did not show up. This was a double-win because the search results were displaying the date of the event post entry, rather than of the event itself, so having to re-code that so it was correct was not a good use of my time.

    IMPLEMENTATION
    1) Create a child theme. That way, the changes you make to functions.php won’t be overwritten when your theme updates. (If a child theme is beyond you, back up and save your current functions.php file offline, then change the file. Make a note in your personal calendar of the file you changed and add a link to this page so you can do it all again if you have to. Real developers, please forgive my sacrilege here.)
    2) Create a redirect page. This is the advisory page where users will be sent to if they don’t have permission to view the calendar or events.
    3) In child’s function.php, copy and paste one or both of the snippets. Be sure to change their temp slug to the actual slug of your redirect page (the comments in the snippet show you how).
    4) If you would like to restrict content on the basis of something other than a user’s logged in state, you will want to change this conditional – “user_is_logged_in” – to the metadata representing the correct state for users who have access (e.g., user must be a member of a defined group, etc.)

    I hope this comment is allowed to remain since I have spent DAYS trying to work around this before getting through this, and I thought a simple explanation would save people LOTS OF WASTED TIME.

    @nico, I defer to you, of course, for any corrections, here, and I thank you for your exceptionally pretty plugin. Finding a beautiful calendar was my top priority, so all the extra functionality is a plus!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Restrict Events Page by User Role’ is closed to new replies.