Home › Forums › Calendar Products › Events Calendar PRO › Updating an Event
- This topic has 22 replies, 3 voices, and was last updated 11 years, 3 months ago by Jonah.
-
AuthorPosts
-
December 3, 2012 at 6:25 pm #28878KyleParticipant
What is the proper syntax for using tribe_update_event to change post_status?
I have been trying to use the wp_update_post array, updateEvent, and tribe_update_event but it is erasing the event meta (Start time, end time, etc.). I wasn’t able to find any example in the codex for them properly.
$update_event = array(); $update_event[‘post_status’]=’draft’; tribe_update_event($post->, $update_order);
The status is updating, but the event meta is being erased…
December 3, 2012 at 6:50 pm #28880JonahParticipantHi Kyle,
Did you look at our documentation for this? https://theeventscalendar.com/support/documentation/the-events-calendar-advanced-functions-event-post-type/#functiontribe_create_event
Can you paste the full code you are working with to http://snippi.com/
Thanks,
JonahDecember 3, 2012 at 8:01 pm #28881KyleParticipantIts tough for me to paste the full code because it is in my payment gateway plugin, I tried to boil it down to just the parts that affect it. The event post status is meant to tie in to Woocommerce order status. http://snippi.com/s/qztnzvb
December 4, 2012 at 6:39 am #28900JonahParticipantHi Kyle,
So this code works for you but is wiping the event meta data?
– Jonah
December 4, 2012 at 6:43 am #28901KyleParticipantHey, thanks for following up
Yes exactly, for some reason any time I use tribe_update_event or wp_update_post with an event post type the start and end times get wiped out.
December 4, 2012 at 6:46 am #28902KyleParticipantI also tried to pass the times back to the post inside the function.
December 4, 2012 at 6:59 am #28904JonahParticipantHi Kyle,
Your code looks good to me so I’m not sure why it’s not working. I’ve passed this on to another developer to see if they can help troubleshoot. Stay tuned.
– Jonah
December 4, 2012 at 7:00 am #28905KyleParticipantJonah;
Okay great, thanks for your help.
Kyle
December 4, 2012 at 5:00 pm #28945SamuelMemberHey Kyle!
Very sorry for the issues you are running into. I also ran into this issue for version 2.0.10 testing the tribe_update_event() function just now, and have another dev coming in to check on it with me who is more involved with that part of the plugin.
For now, i did also test wp_update_post() and found all my meta and event date did hold.
Setting an event to draft from published worked fine for me running something like this:
http://snippi.com/s/5hqp00s
Can you verify your wp_update_post function is really wiping the meta/date while we look into resolving this bug? Is it totally removing the dates when using wp_update_post()?Thanks so much!
sam
December 4, 2012 at 5:59 pm #28949KyleParticipantHey Sam, thanks for following up on this. I think I actually was able to figure out part of the problem. I had a separate function that was hooked into save_post which was causing an infinite loop (but only with events, which is why I thought it was with tribe_update_event). I appreciate you taking the time with this
December 4, 2012 at 6:11 pm #28950SamuelMemberHey Kyle! So tribe_update_event() is working for you now? Because a test of the function for me in a clean dev environment did produce the same effect, wiping of meta and start/end time. sam
December 4, 2012 at 6:13 pm #28951KyleParticipantHey
I switched over to wp_update_post, but I will test with tribe_update_event
December 4, 2012 at 6:17 pm #28952SamuelMemberThat would be great if you could report back on that, I definitely experienced the same as you, but wp_update_post was fine. Thank you for taking the time!
December 4, 2012 at 7:24 pm #28954KyleParticipantOkay, so after playing with the tribe_update_event function for awhile it seems that you simply have to pass the entire date/time variable back in the correct format each time, or it will reset the date. So something like this http://pastie.org/5482011 will work. It is essentially like using the tribe_create_event function each time.
December 4, 2012 at 8:02 pm #28955SamuelMemberThanks Keith, I was beginning to find the same thing. I’m going to take a look at whether we can update the saveEventMeta function tied into create/update to be smarter in the case of updating. If not I’ll get the docs updated. Thank you again for taking the time to give feedback, appreciated!
Sam
-
AuthorPosts
- The topic ‘Updating an Event’ is closed to new replies.