Add Alarm to Event

Home Forums Calendar Products Events Calendar PRO Add Alarm to Event

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #18665
    Andy Fragen
    Moderator

    I’ve finally figured out how to add an alarm to an event.

    Start by creating an Additional Field from the Settings. I named mine ‘Alarm’ of type ‘Dropdown’ with values of “Off,15,30″. The values are each on their own line. Now when editing or creating an event you can set the additional field value for how many minutes in advance of the event you wish to be notified. If you don’t want an alarm either do nothing or choose ‘Off”.

    Now add the following code to events-calendar-pro.php in the iCalFeed function.

    $alarm = tribe_get_custom_field('Alarm', $eventPost->ID);
    if ( is_numeric($alarm) ) {
    $item[] = 'BEGIN:VALARM';
    $item[] = 'TRIGGER:-PT' . $alarm. "M";
    $item[] = 'END:VALARM';
    }

    I chose to insert it after the line $item[] = 'URL:' . get_permalink( $eventPost->ID );
    You should now get alerts for your events. Clearly there is much more that can be done with this code and I hope it gets incorporated into 2.1

    #18722
    Jonah
    Participant

    Hi Andy,

    This is excellent! Thank you so much! While I can’t guarantee it will get incorporated, it is none the less a great addition. I have an improvement though that doesn’t require modifying the core files by filtering the $item array like so:

    https://gist.github.com/2597140

    Just pop that in your functions.php file, create the “Alert” custom field in Settings > The Events Calendar and add the alert times within your event that you want to have an alert.

    Credit for this goes to one of our developers, Joey Kudish and of course you Andy, for coming up with the idea in the first place.

    I hope you find this useful!

    Cheers,
    Jonah

    #18726
    Andy Fragen
    Moderator

    Jonah,

    Excellent, I’m so glad there’s a way to add this without modifying the core. I just didn’t know how. I’m glad you put in the filter hooks. This is beautiful.

    I made few changes to the code which you and Joey can look at here.

    https://gist.github.com/2599350

    I added a test for test for is_numeric in addition to the empty test. That and the string conversion to integer is unnecessary.

    Thanks,
    Andy

    #18741
    Andy Fragen
    Moderator

    Jonah/Joey,

    I decided to rewrite this as a WP plugin that way all anyone else who wants this functionality has to do is download the plugin and activate it. They will also need to create the Additional Field as described above, but this way they won’t have to change their own theme functions.php file. And if/when tri.be incorporates similar functionality all that has to be done is deactivate the plugin.

    You can get it, pound on the code, or otherwise enhance, improve or change it from GitHub.

    https://github.com/afragen/events-calendar-pro-alarm

    If I need to add/change anything so I’m not infringing on tri.be’s work etc. let me know. It’s the last thing I want to do.

    Thanks,
    Andy

    #18753
    Jonah
    Participant

    Hi Andy,

    That’s most awesome, thank you so much! I’m going to create a short blog post hopefully sometime this week highlighting the plugin you wrote 🙂

    Thanks again,
    Jonah

    #18966
    Andy Fragen
    Moderator

    Jonah, if your going to write up a post I’ve gotten the plugin uploaded to the WP Plugin Repository.

    http://wordpress.org/extend/plugins/the-events-calendar-pro-alarm/

    Shane gave me the nudge and thanks to Brent @ http://thereforei.am/2011/04/21/git-to-svn-automated-wordpress-plugin-deployment/ for a simple Git -> SVN deployment script.

    #19171
    Rob
    Member

    Thank you Andy! just returned from vacation and am catching up the threads, and this is super solid. The whole community wins 🙂

    #976816
    Support Droid
    Keymaster

    This topic has not been active for quite some time and will now be closed.

    If you still need assistance please simply open a new topic (linking to this one if necessary)
    and one of the team will be only too happy to help.

Viewing 8 posts - 1 through 8 (of 8 total)
  • The topic ‘Add Alarm to Event’ is closed to new replies.