Posted: June 10, 2019 at 12:50 am
|
I have found that when you duplicate an event, not all data will be copied over. Namely the followings:
I have seen previous posts mention similar issues. But it seems these two issues were never fixed? Any solution here. Cheers Hody |
Hi Hody,
This is something we can look into adding into the MailChimp add-on as it’s easier to wipe out the settings than it is to re-apply them if you have multiple lists/groups/question relationships. For example, if you duplicate the event and the settings are copied over but you don’t want them, you can simply set the event to not subscribe to a list and update to wipe out the settings and step fresh. I imagine copying all of the options manually if you have multiple groups etc would get annoying. I’ve created a ticket for us to investigate this further.
This is something we will need to discuss further internally as if I recall correctly this was a design choice rather than a bug so this may not be something we add to core. There’s a hook available that can be used to do whatever you want to do when an event is duplicated, that hooks is AHEE__Extend_Events_Admin_Page___duplicate_event__after which is passed the ‘new’ EE event object (the duplicate) and the ‘original’ event object. So in the meantime, you could add your own function to copy whatever custom fields (or all of them) if you prefer. |
|
|
Hi Tony, appreciate you looking at the Mailchimp issue. As there is quite a few event items we had to go through and we just want them to be opt into the same list with same group. But each time we had to redo them. Thanks for the hook. Will definitely look into it. Thanks |
Sure, you have the EE_Event object for both the new and original events so you can do whatever you need to do. The hook is fired after everything has been created. If you’re asking for an example of how to do the above, I don’t have one as its not something we currently support, but if you work through the |
|
|
Hi Tony, I attempted to get the following code snipet to work, but no luck.
|
|
The error messages was: Error message: Uncaught Error: Call to a member function get_many_related() on null … It looks like the get_many_related() is not returning anything. |
The problem is not that Your add_action call isn’t valid, your callback function expects 2 paramaters yet you are not telling the hook to pass 2 parameters, when testing your code I get a different fatal:
You fix that by fixing your add_action call:
From there I get valid new_event and orig_event parameters with EE_Event objects, but your code throws another error, you’ll need to review and fix. |
|
|
Hi Tony, With your help, I have got rid of the errors. But now the problem was to set the $date variable for both
|
|
For the custom fields, the following code snippets will duplicate all the custom fields data over:
|
You’re missing a However, I did a little digging into this and as far as I can tell A quick fix is to add this after your code:
Then save, so it would look something like:
That should update the DateTime in the DB as — With regards to the post meta values, thanks for sharing your code but something to note is that the above is fairly inefficient and may fail if you have a lot of custom fields. |
|
|
Yes, this works! Thanks for the tips. So basically the time also need to be updated in order to flag it. Regarding to the meta value, would there be a better way to do? I am not updating a lot, so it should be fine. But a better method would be beneficial for others to utilise for the future. |
No, it’s not the time, it’s a bug in the methods used. In short
I’ve created a ticket for our developers to investigate this further as I believe the above methods should be setting that flag but for now, the above is needed (and it won’t cause issues if this is ‘fixed’ in core).
Sure there is, you can do it in just 2 queries, take a look here: |
|
Judging by other posts, it appears this issue may be a few years old. Should we just follow Hody’s example and fix it ourselves, or should we expect a fix for this from EE soon? |
|
Which issue are you referring to? The datetime issue in which using Including the MailChimp event settings when the duplicating an event has been added to the next version of MailChimp. Duplicating custom fields is by design, although can be done with a snippet. As it stands we don’t have plans to include anything within core to duplicate custom fields. |
|
Just noting here that the latest version of the MailChimp add-on has just been pushed live. If you don’t see the update just yet go to Event Espresso -> General Settings and hit save. That will force a version check and should show the update. |
|
The support post ‘Bug / issue on Duplicate event’ 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.