Get event meta field after creating an event
-
Hello,
I am creating an event with the ORM like this:
$new_event = tribe_events()->set_args($event)->create(); // Set meta field to the event add_post_meta($new_event->ID, '_meta_field', $meta_field);
After that, I need to get the value of this meta field when the event is created and I do this:
add_action('save_post_tribe_events', 'get_meta_field'); function get_meta_field($event_id) { $meta_field = get_post_meta($event_id, '_meta_field', true) }
But I get nothing when the event is published. But, when I delete the event, the hook also fires and this time I have the meta field value. The thing is, I need the data when the event is published.
I tried this with other hooks like wp_insert_post or wp_after_insert_post but to no avail. I also tried to get $_POST[‘_meta_field’], but also nothing.
What can I do?
Thank you
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘Get event meta field after creating an event’ is closed to new replies.