Use of wp_insert_post() with action 'publish_tribe_events' causes event 404s

Home Forums Calendar Products Events Calendar PRO Use of wp_insert_post() with action 'publish_tribe_events' causes event 404s

Viewing 11 posts - 1 through 11 (of 11 total)
  • Author
    Posts
  • #954350
    37designs
    Participant

    Hello,

    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?

    #954502
    Josh
    Participant

    Hey,

    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!

    #954616
    Josh
    Participant

    Hey,

    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!

    #954624
    37designs
    Participant

    Hey 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.

    #955220
    Josh
    Participant

    Hey,

    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!

    #956390
    37designs
    Participant

    Any 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.

    #956846
    Josh
    Participant

    Hey 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!

    #956854
    37designs
    Participant

    Thanks,

    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
    -Ross

    #957399
    Josh
    Participant

    Hey 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!

    #965824
    Leah
    Member

    Hi 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 Team

    #1001854
    Leah
    Member

    Hello,

    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

Viewing 11 posts - 1 through 11 (of 11 total)
  • The topic ‘Use of wp_insert_post() with action 'publish_tribe_events' causes event 404s’ is closed to new replies.