Single Event Recurring Occurrence Date

WordPress Event Management, Calendars & Registration Forums General Question Single Event Recurring Occurrence Date

This topic contains 1 reply, has 2 voices, and was last updated by  Stephen Harris 7 years, 1 month ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #29405

    I don’t think this is possible with php, so I did it with jQuery. I added the occurrence date to a parameter on the url and then grabbed that and stuck it in the html, so that both the recurring and the non-recurring have similar date formatting in the entry header area. I believe I’ve hunted through your codex and couldn’t find anything that did this. Did I miss something?

    enter image description here

    Joy Katzen-Guthrie
    #29419

    No, the plug-in doesn’t render date-specific pages for the recurring events. The one page serves all occurrences.

    That said, there’s nothing wrong with you’re doing. Event Organiser doesn’t do this by default because it can’t, generally, and reliably insert the date parameter in every instance of links to the event page.

    I would however recommend that you use the occurrence ID in the URL rather than formatted date, and just inserting that. Doing so means if someone were to alter the URL and change the date it would appear the event is occurring on a date that is not. Even if that seems unlikely, someone might bookmark the URL, and then the occurrence is removed/changed; that user would visit the URL and it would look like the event is still running on that date. Lastly, you’re probably escaping the formatted date before rendering it, but sanitising an occurrence ID (an integer) is far more straightforward and restrictive.

    By using an occurrence ID you can display the correct (and possibly changed) datetime and you can easily check if the occurrence ID is invalid and display an error message / redirect to 404 / display the default event page if it’s not.

    Once you retrieve the occurrence ID:

    try { 
       $formattedDate = eo_get_the_start( 'M d, Y', get_the_ID(), (int) $occurrence_id );
       //print formatted date.
    } catch ( \Exception $e ) {
       //invalid occurrence ID
    }
    
    Stephen Harris
Viewing 2 posts - 1 through 2 (of 2 total)
To enable me to focus on Pro customers, only users who have a valid license for the Pro add-on may post new topics or replies in this forum. If you have a valid license, please log-in or register an account using the e-mail address you purchased the license with. If you don't you can purchase one here. Or there's always the WordPress repository forum.