tribe_create_venue() doesn't set venue title

Home Forums Calendar Products Events Calendar PRO tribe_create_venue() doesn't set venue title

Viewing 15 posts - 1 through 15 (of 15 total)
  • Author
    Posts
  • #71769
    Oliver
    Participant

    Hi there!

    I’m working on a php script to import data into Events Calendar Pro, but got stuck with two problems:

    1. For creating an venue I use this code
    (as described here: http://docs.tri.be/Events-Calendar/function-tribe_create_venue.html):

    $venue = array();
    $venue[“Venue”] = $location;
    // $venue[“post_title”] = $location; // Doesn’t work neither
    $venue[“post_type”] = “tribe_venue”;
    $event[“post_status”] = “pending”;
    $venue[“EventCountry”] = $country; // $venue[“Country”] doesn’t work! Looks like the documentation above is outdated!
    $venue[“Address”] = $street;
    $venue[“City”] = $city;
    $venue[“Zip”] = $zip;
    $venue[“ShowMap”] = true;
    $venue[“ShowMapLink”] = true;
    $venue[“URL”] = $url;
    $VenueID = tribe_create_venue($venue);

    The venue is created, but the title (post_title) is set to “Unnamed Venue”.
    I also tried to add this, but the title still stays the same:

    if ($VenueID != false)
    {
    $my_post = array(
    ‘ID’ => $VenueID,
    ‘post_title’ => ‘Another title.’
    );
    wp_update_post( $my_post );

    If I use ‘post_content’ => ‘Another content.’ it works, which is very irritating!

    2. For creating the event (which should link to the venue) I use this code
    (as described here: http://docs.tri.be/Events-Calendar/function-tribe_create_event.html):

    $event = array();
    $event[“post_title”] = $title; // Here post_title works! 🙂
    $event[“post_status”] = “pending”;
    $event[“post_type”] = “tribe_events”;
    $event[“post_content”] = $description;
    $event[“EventStartDate”] = $start_date;
    $event[“Venue”] = $VenueID;
    $post_id = tribe_create_event($event);

    Unfortunately the venue is not linked to the event.
    For both problems I tried a lot of workarounds and research, but didn’t find any working solution.
    Do you have an idea?

    Best regards,
    Oliver

    #72027
    Barry
    Member

    Hi Oliver,

    Instead of passing a post_title parameter have you tried using Venue?

    http://docs.tri.be/Events-Calendar/function-tribe_create_venue.html

    Let me know if that helps!

    #72099
    Oliver
    Participant

    Hi Barry,

    yes I did (see code above):
    $venue[“Venue”] = $location;
    // $venue[“post_title”] = $location; // Doesn’t work neither

    Regards,
    Oliver

    #72188
    Oliver
    Participant

    I also tried, but it still doesn’t work.

    if ($VenueID != false)
    {
    $my_post = array(
    ‘ID’ => $VenueID,
    ‘Venue’ => ‘Another title.’
    );
    wp_update_post( $my_post );

    Can you reproduce this problem on your side?

    #72232
    Barry
    Member

    Hi Oliver,

    Thanks for bearing with us.

    Yes that definitely needs some attention; the problem (or one of the primary problems) is that despite the comments in the code that function isn’t currently geared towards being used “at will” – instead, for venues to be set up correctly, much hangs on the presence of data in the $_POST superglobal array (which of course isn’t present since you are trying to do this programmatically).

    For the time being at least I’d recommend using WordPress’s own API functions to build venues – but I’ll certainly list this on the bug tracker as something to be addressed.

    Thanks for your patience!

    #72406
    Oliver
    Participant

    Hi Barry,

    thanks for the answer. I have three questions:

    1. Is it possible to fill the $_POST array with additional data? If yes, which data is needed?
    2. If no, can you post a piece of code or a link with an example for creating a venue via the WordPress API?
    3. My second questions from the beginning of this thread isn’t discussed yet. Can you give me a hint how to make the link between the event and the venue work?

    Both parts are essiential as I need to migrate the data from our old productive system (Joomla) to the new (WordPress) with Events Calendar. We have several thousand events which needs to be imported in the new system. This can’t be done manually as you will understand 😉

    Best regards,
    Oliver

    #72416
    Oliver
    Participant

    PS: I found this link with another (???) API:
    http://plugins.trac.wordpress.org/browser/the-events-calendar/tags/3.0.1/lib/tribe-event-api.class.php#L12

    Is this API a possible solution? What’s the difference of the both APIs?

    #72600
    Barry
    Member

    Hi Oliver,

    Is it possible to fill the $_POST array with additional data? If yes, which data is needed?

    That is a possible avenue. I might even do it myself (!) yet I wouldn’t actually recommend it as it isn’t the very cleanest way to do things, could have unintended side effects and therefore may merit more scrutiny than it’s worth when other and arguably better approaches are available.

    Essentially though a venue is nothing but a post with some post meta data attached – you can create new posts with wp_insert_post() and of course set post meta data with update_post_meta() and other related functions.

    The best advice I can really offer though – because even supposing tribe_create_venue() was functional this would be a piece of customization work that we can’t offer support for – is to look at existing entries in the database created through the admin interface. That will give you a much better sense of the relationship between different entities than I can provide here. For a brief pverview of the custom (post meta) fields you are likely to be interested in, see here.

    Is this API a possible solution? What’s the difference of the both APIs?

    Not much 🙂

    tribe_create_venue() for example is effectively just an alias of TribeEventsAPI::createVenue().

    Because we unfortunately can’t help with customizations like this I’ll need to go ahead and close this thread now – but I do wish you luck here and we will certainly endeavour to repair tribe_create_venue() for a forthcoming release.

    Thanks!

    #73743
    Oliver
    Participant

    Hi Barry,

    thanks for reopening this post and creating a bug report.

    The tribe_create_venue() is not working the way as described in the documentation. It’s definitly a BUG, already described in July 2013:

    Problems with migration from v2 to v3


    Unfortunately it’s still not fixed in the current release! I recommend everybody not to use this function until the bug is fixed!!!

    Currently I’m using the following workaround:
    I create the complete event including the venue. I hope this helps everybody who is dealing with the same problem.

    $venue = array();
    $venue[‘Venue’] = $location;
    $venue[‘post_type’] = ‘tribe_venue’;
    $venue[‘EventCountry’] = ‘Deutschland’; // Documentation is wrong, it has to be EventCountry, not Country!
    $venue[‘Address’] = $street;
    $venue[‘City’] = $city;
    $venue[‘State’] = ”;
    $venue[‘Province’] = ”;
    $venue[‘Zip’] = $zip;
    $venue[‘ShowMap’] = true;
    $venue[‘ShowMapLink’] = true;
    $venue[‘Phone’] = $phone;
    $venue[‘URL’] = $url;

    $event = array();
    $event[‘post_title’] = $title;
    $event[‘post_status’] = ‘pending’;
    $event[‘post_type’] = “tribe_events”;
    $event[‘post_content’] = $description;
    $event[‘EventStartDate’] = $start_date; // YYYY-MM-DD
    $event[‘EventEndDate’] = $end_date; // YYYY-MM-DD
    $event[‘EventAllDay’] = ‘yes’; // Tribe documentation is wrong, it has to be “yes” or false !!!
    $event[‘EventHideFromUpcoming’] = false;
    $event[‘EventShowMapLink’] = true;
    $event[‘EventShowMap’] = true;
    $event[‘EventCost’] = ”;

    $event[‘Venue’]=$venue;

    $post_id = tribe_create_event($event);

    Best regards,
    Oliver

    #73890
    Barry
    Member

    Thanks for posting back with that solution, Oliver. Just to give you a complete picture at this point any fix is unlikely to make the very next maintenance release – but we’ll definitely aim to incorporate the needed changes as quickly as possible.

    Thanks again for your support and patience 🙂

    #74207
    Oliver
    Participant

    Ok, thanks for the info. I hope the fix make it in the over next release 😉

    In the meanwhile my recommendation would be to change the wrong documentation (see notes above) and make a link to the workaround. It took me around 10 hours to find the solution and other would be obviously happy to avoid this effort 🙂

    #74585
    Barry
    Member

    Due to the way our systems work we probably won’t see a change in the very next release but we’ll do what we can 🙂

    Thanks again (and I’ll go ahead and close this thread).

    #74878
    Kelly
    Participant

    Hi, Oliver. This is just a note to let you know that we did not, in fact, get a chance to look at your issue for our maintenance release this time around.

    We do plan to find a way to help you out with this. We look forward to addressing this as soon as we’ve got bandwidth/resources to allow it.

    Thanks for being part of the TEC community!

    #95342
    Leah
    Member

    Hi there,

    I’m happy to report that we have fixed this in our upcoming version 3.4. Keep an eye on your Plugins page for an update message! Thanks for your patience while we worked on this.

    Best,
    Leah

    #982962
    Support Droid
    Keymaster

    This topic has not been active for quite some time and will now be closed.

    If you still need assistance please simply open a new topic (linking to this one if necessary)
    and one of the team will be only too happy to help.

Viewing 15 posts - 1 through 15 (of 15 total)
  • The topic ‘tribe_create_venue() doesn't set venue title’ is closed to new replies.