Support

Home Forums Event Espresso Premium Duplicate event with custom field

Duplicate event with custom field

Posted: March 6, 2018 at 3:41 am

Viewing 1 reply thread


motio

March 6, 2018 at 3:41 am

Hey,

I would like to copy also the custom fields when I duplicate an event. I found this topic in the forum (e.g. https://eventespresso.com/topic/event-import/ and https://eventespresso.com/topic/hooking-into-the-private-function-_duplicate_event/) but can’t get it to work.

Here is what I’ve tried:

function duplicate_custom_field($new_event, $orig_event) {
//duplicate custom field
$desc = get_post_meta($orig_event->ID(), 'desc', true);
if ($desc) {
update_post_meta($new_event->ID(), 'desc', $desc);
}
}
add_action( 'AHEE__Extend_Events_Admin_Page___duplicate_event__after', 'duplicate_custom_field', 10, 2 );

‘desc’ is a custom field (via acf) which should be duplicated too.


motio

March 6, 2018 at 3:48 am

The code was correct, there was an error on a different spot.

Viewing 1 reply thread

The support post ‘Duplicate event with custom field’ is closed to new replies.

Have a question about this support post? Create a new support post in our support forums and include a link to this existing support post so we can help you.

Event Espresso