Home › Forums › Calendar Products › Events Calendar PRO › Use of wp_insert_post() with action 'publish_tribe_events' causes event 404s
- This topic has 10 replies, 3 voices, and was last updated 10 years, 8 months ago by
Leah.
-
AuthorPosts
-
April 9, 2015 at 9:05 am #954350
37designs
ParticipantHello,
I’m working on a site where we need to create a post with information about an event automatically when the event is published. What I’ve found is that if I use the wp_insert_post() function along with the publish_tribe_events the single event pages result in a 404. I’ve also noticed that the date for these events in the WP admin doesn’t match the standard format, instead of April 9th, it will say 04/09/2015.
Here is some of the code I’m using:
add_action(‘publish_tribe_events’,’df_create_teaser_post’,9999);
$args = array(
‘post_content’ => $content,
‘post_title’ => get_the_title($post),
‘post_status’ => ‘publish’
);// This is the teaser about the event
$event_post = wp_insert_post($args,$wp_error);// Let this event know there is a child post tied to this one.
update_post_meta($post,’_event_post_child’,$event_post);Any thoughts?
April 9, 2015 at 7:52 pm #954502Josh
ParticipantHey,
Thanks for reaching out to us!
I tested the code above and noticed the same issues you’re describing. I tried a modified version using a different hook yet still continued to experience the same 404 issue on the newly created events. To be honest I’m not sure exactly what’s going on in this process.
I’ll reach out to one of our developers tomorrow about this issue to see if they have some insight into what may be happening here.
I’m sorry for the inconvenience but hopefully we can get to the bottom of this issue quickly.
Thanks!
April 10, 2015 at 10:29 am #954616Josh
ParticipantHey,
I did a little more research and found something that may be useful in this situation. It looks like the issue revolves around how “wp_insert_post()” is used in core for the different update/publish actions. Check out this comment on StackExchange to see if it helps to format a different approach to inserting the post http://wordpress.stackexchange.com/a/88335.
Let me know if this helps.
Thanks!
April 10, 2015 at 10:40 am #95462437designs
ParticipantHey Josh,
I was using transition_post_status previously and was encountering the same issue.
My theory is that TEC runs a post-save function by default and my using wp_insert_post(); somehow interrupts it. This would explain why the date format is wrong in addition to the events 404ing.
If that is the case, maybe I can call it manually within my function after inserting the post?
Of course this is all speculation so I could be completely off.
April 13, 2015 at 2:50 pm #955220Josh
ParticipantHey,
This may very well be the case. We do have some stuff that runs on “save_post”. In the past, we have seen issues where functions hooked to “save_post” with a priority 15 or higher causes some issues when saving the postmeta. This could be somewhat at play here. I tested the above snippet at a lower priority but continued to have the same issue so that doesn’t seem to be the same issue at play here.
I’ll reach out to our team again with this updated information to see if we can get further insight. I apologize for the inconvenience and hopefully we can work to get to the bottom of this issue.
Thanks!
April 17, 2015 at 1:32 pm #95639037designs
ParticipantAny luck on this? If you don’t think we’ll have any insight by Monday morning can you let me know? I’ll need to find some complicated work around (like trying to double save the post or something) if that’s the case.
April 20, 2015 at 3:00 pm #956846Josh
ParticipantHey 37designs,
I apologize for the delay. I’ll be bringing it up to the team during our meeting tomorrow. Depending on the conversation, this issue will potentially become a bug ticket in our system and get addressed in an upcoming release.
Thanks!
April 20, 2015 at 3:13 pm #95685437designs
ParticipantThanks,
For the time being I added a link to the MISC meta box on published events that will create a post when clicked. It’ll work for the time being 🙂
Best
-RossApril 22, 2015 at 9:12 am #957399Josh
ParticipantHey Ross,
I’m glad you were able to find a temporary workaround for the issue. I’ve added this thread to our internal ticket for tracking this issue and you’ll be notified here as we make progress on this one.
I’ll go ahead and close this thread for now. If you have any further questions, please don’t hesitate to open a new one.
Thanks!
May 28, 2015 at 12:33 pm #965824Leah
MemberHi there,
Thanks again for your post. We wanted to get in touch and let you know that although we weren’t able to address this issue in our upcoming 3.10 release, it is still very much a priority. We have a ticket in our system and will be investigating a solution to be released in a future version. Thank you for your patience and support while we work on this!
Cheers,
The Events Calendar TeamSeptember 3, 2015 at 3:46 pm #1001854Leah
MemberHello,
Thank you so much for reporting this. We are happy to tell you that a solution to this issue is part of our upcoming 3.12 release! We are doing the final testing and then the new version will be released. Keep an eye on your dashboard Updates page!
If you experience any difficulty with the update or find that the issue you reported in this thread is not resolved in 3.12, please open a new thread and we can help you. Thank you for your patience and support as we work to improve our plugins!
Best,
Leah
and The Events Calendar team -
AuthorPosts
- The topic ‘Use of wp_insert_post() with action 'publish_tribe_events' causes event 404s’ is closed to new replies.
