Home › Forums › Calendar Products › Community Events › Get Event ID On Submit From Frontend
- This topic has 19 replies, 3 voices, and was last updated 10 years, 9 months ago by
Support Droid.
-
AuthorPosts
-
February 14, 2013 at 12:49 pm #32670
Dan
ParticipantI am adding some custom meta boxes to the frontend submission form of community events by adding the code to the events-meta-box.php template. I would like to be able to run an action on event submission (or update) from the frontend to save the values from these fields. Is there an action that runs on event submission (or update) and does it return (or how can I get) the event ID? (PS, I’m not using the additional fields option in Events Calendar Pro because I want to style my meta boxes very specifically).
Thanks.
February 15, 2013 at 10:12 am #32761Casey
ParticipantDan,
Thanks for getting in touch. I’ll pose this question to our developers and see what they say. Please stand by. Thanks!February 15, 2013 at 12:26 pm #32780Casey
ParticipantDan,
It looks like you could take advantage of the ‘tribe_events_update_meta’ action to grab the Event ID. You could add something like this to your functions.php: https://gist.github.com/ckpicker/4963260Take a look at the ‘updateEvent’ & ‘saveEventMeta’ functions in ‘wp-content/plugins/the-events-calendar/lib/tribe-event-api.class.php.’
That should get you most of the way there. Good luck, and let me know if you have further questions!
February 19, 2013 at 10:42 am #32991Casey
ParticipantDan,
I just wanted to check back in and see if the code I shared above was what you were looking for. Just let me know. Thanks!February 19, 2013 at 7:20 pm #33025Dan
ParticipantCasey,
Thanks for your quick responses. I was recently pulled onto another project and haven’t had a chance to investigate your suggestion. I will let you know how it goes when I can try it out.Thanks!
February 20, 2013 at 6:59 am #33046Casey
ParticipantThanks Dan! Just let us know.
February 20, 2013 at 1:52 pm #33087Dan
ParticipantCasey,
So I looked into it. Will this action also trigger when saving an event in the backend? Currently I am using ‘save_post’ action to trigger my function to save the post meta in the backend. Can I remove that hook and still have my function triggered from tribe_events_update_meta?
Thank!February 20, 2013 at 2:01 pm #33090Casey
ParticipantDan,
Yes, that’s correct. This action gets triggered when an events is created, saved, or updated. Hope that helps!February 20, 2013 at 2:05 pm #33091Casey
ParticipantDan,
Unless you have other questions, I’m going to mark this thread “Answered” and close it out.We really appreciate your support and please let us know if you need anything else in the future. If you find yourself with a few minutes and would be so kind as to give us a “Works” rating or a positive star voting on the WordPress.org repo (http://wordpress.org/extend/plugins/the-events-calendar/), or even a shoutout to your followers on Facebook or Twitter, it would mean a lot to us. Thanks again for using the plugin.
February 21, 2013 at 7:03 am #33115Dan
ParticipantCasey,
Unfortunately, it doesn’t appear that the tribe_events_update_meta hook is triggered when events are saved via community events. The meta is saved when on the backend, however.add_action( ‘tribe_events_update_meta’, ‘pcs_save_trash_meta’, 10, 1 );
function pcs_save_trash_meta($post_id) {
global $post;
$post_id = (int) $post_id;
var_dump($post_id); exit();
}With the above code in my functions.php file, the “Event submitted.” page shows up after submission with no exit() command called. The database also has not been updated.
February 21, 2013 at 7:10 am #33116Casey
ParticipantDan,
Stand by while I pass this question on to one of our developers. Thanks!February 21, 2013 at 11:49 am #33139Casey
ParticipantDan,
We had one of our developers try this, and he was able to get the function to trigger. Here was his code:https://gist.github.com/ckpicker/5007550
Just to confirm, are you using version 1.0.4? Our developer is using EC 2.0.11 and Community 1.0.5.
Also, can you confirm that you’re seeing the output of var_dump when adding a new event using the back-end ‘Add Event’ form in the dashboard?
February 21, 2013 at 2:47 pm #33153Dan
ParticipantCasey,
That is correct. I am not able to see the output of var_dump on the frontend. I have updated to 2.0.11 and 1.0.5. In the backend, I see the var_dump and exit() triggered.From the source code, it looks like the only problem could be with the file tribe-event-api.class.php. In the updateEvent function saveEventMeta is only triggered if wp_update_post($args) returns true…
Thanks.February 21, 2013 at 3:04 pm #33155Dan
ParticipantCasey,
When adding a new event from the front end, the tribe_events_update_meta action is triggered.February 21, 2013 at 3:05 pm #33156Casey
ParticipantSo, it is being triggered in both places for you now?
-
AuthorPosts
- The topic ‘Get Event ID On Submit From Frontend’ is closed to new replies.
