Home › Forums › Calendar Products › Events Calendar PRO › tribe_create_venue() doesn't set venue title
- This topic has 14 replies, 5 voices, and was last updated 10 years, 9 months ago by
Support Droid.
-
AuthorPosts
-
October 20, 2013 at 3:36 am #71769
Oliver
ParticipantHi 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,
OliverOctober 21, 2013 at 12:28 pm #72027Barry
MemberHi 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!
October 21, 2013 at 3:33 pm #72099Oliver
ParticipantHi Barry,
yes I did (see code above):
$venue[“Venue”] = $location;
// $venue[“post_title”] = $location; // Doesn’t work neitherRegards,
OliverOctober 21, 2013 at 11:20 pm #72188Oliver
ParticipantI 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?
October 22, 2013 at 6:23 am #72232Barry
MemberHi 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!
October 22, 2013 at 2:19 pm #72406Oliver
ParticipantHi 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,
OliverOctober 22, 2013 at 3:21 pm #72416Oliver
ParticipantPS: 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#L12Is this API a possible solution? What’s the difference of the both APIs?
October 23, 2013 at 4:34 pm #72600Barry
MemberHi 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!
October 30, 2013 at 1:55 am #73743Oliver
ParticipantHi 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:
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,
OliverOctober 30, 2013 at 4:35 pm #73890Barry
MemberThanks 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 🙂
November 1, 2013 at 3:04 am #74207Oliver
ParticipantOk, 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 🙂
November 4, 2013 at 12:58 pm #74585Barry
MemberDue 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).
November 5, 2013 at 3:34 pm #74878Kelly
ParticipantHi, 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!
January 21, 2014 at 2:50 pm #95342Leah
MemberHi 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,
LeahJuly 7, 2015 at 6:30 am #982962Support Droid
KeymasterThis 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. -
AuthorPosts
- The topic ‘tribe_create_venue() doesn't set venue title’ is closed to new replies.
