Home › Forums › Calendar Products › Events Calendar PRO › Add Alarm to Event
- This topic has 7 replies, 4 voices, and was last updated 8 years, 8 months ago by Support Droid.
-
AuthorPosts
-
May 3, 2012 at 6:47 pm #18665Andy FragenModerator
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.1May 4, 2012 at 4:18 pm #18722JonahParticipantHi 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,
JonahMay 4, 2012 at 8:23 pm #18726Andy FragenModeratorJonah,
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,
AndyMay 6, 2012 at 10:42 am #18741Andy FragenModeratorJonah/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,
AndyMay 7, 2012 at 9:18 am #18753JonahParticipantHi 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,
JonahMay 9, 2012 at 5:43 pm #18966Andy FragenModeratorJonah, 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.
May 14, 2012 at 7:26 pm #19171RobMemberThank you Andy! just returned from vacation and am catching up the threads, and this is super solid. The whole community wins 🙂
July 7, 2015 at 6:20 am #976816Support DroidKeymasterThis 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. -
AuthorPosts
- The topic ‘Add Alarm to Event’ is closed to new replies.