Get Event ID On Submit From Frontend

Home Forums Calendar Products Community Events Get Event ID On Submit From Frontend

Viewing 15 posts - 1 through 15 (of 20 total)
  • Author
    Posts
  • #32670
    Dan
    Participant

    I 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.

    #32761
    Casey
    Participant

    Dan,
    Thanks for getting in touch. I’ll pose this question to our developers and see what they say. Please stand by. Thanks!

    #32780
    Casey
    Participant

    Dan,
    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/4963260

    Take 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!

    #32991
    Casey
    Participant

    Dan,
    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!

    #33025
    Dan
    Participant

    Casey,
    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!

    #33046
    Casey
    Participant

    Thanks Dan! Just let us know.

    #33087
    Dan
    Participant

    Casey,
    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!

    #33090
    Casey
    Participant

    Dan,
    Yes, that’s correct. This action gets triggered when an events is created, saved, or updated. Hope that helps!

    #33091
    Casey
    Participant

    Dan,
    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.

    #33115
    Dan
    Participant

    Casey,
    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.

    #33116
    Casey
    Participant

    Dan,
    Stand by while I pass this question on to one of our developers. Thanks!

    #33139
    Casey
    Participant

    Dan,
    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?

    #33153
    Dan
    Participant

    Casey,
    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.

    #33155
    Dan
    Participant

    Casey,
    When adding a new event from the front end, the tribe_events_update_meta action is triggered.

    #33156
    Casey
    Participant

    So, it is being triggered in both places for you now?

Viewing 15 posts - 1 through 15 (of 20 total)
  • The topic ‘Get Event ID On Submit From Frontend’ is closed to new replies.