Home › Forums › Calendar Products › Events Calendar PRO › (Solved) How can I set a pre-defined venue via php?
- This topic has 3 replies, 2 voices, and was last updated 12 years, 2 months ago by
Barry.
-
AuthorPosts
-
February 10, 2014 at 9:33 am #102684
efromdc
ParticipantIm doing the following to import some data from a csv file via php:
$venueData = array();
$venueData[‘Venue’] = venuename
$venueData[‘post_type’] = ‘tribe_venue’;
$venueData[‘Country’] = country;
$venueData[‘Address’] = address;
$venueData[‘City’] = city;
$venueData[‘State’] = state;
$venueData[‘Zip’] = zip;
$venueData[‘ShowMap’] = true;
$venueData[‘ShowMapLink’] = true;
$venueData[‘Phone’] = phone;
$venueData[‘URL’] = url;
$event[‘Venue’]=$venueData;
$event[‘post_title’] = Title;
$event[‘post_status’] = ‘pending’;
$event[‘post_type’] = ‘tribe_events’;
$event[‘post_author’] = $postAuthor;
$event[‘post_content’] = $postBody;
$event[‘EventStartDate’] = date(“Y-m-d H:i:s”, now());
$event[‘EventEndDate’] = date(“Y-m-d H:i:s”, ‘+1 day’);
$event[‘EventShowMapLink’] = true;
$event[‘EventShowMap’] = true;$postID = tribe_create_event($event);
This works fine (I might have an error in the code above as I wrote this off the top of my head, but you get the point).
1. How do I test to see if a venue already exists in my db? For example, if the venue name in the csv is “my place” but I already have “my place” defined in the database, I dont want to create a second instance. I want to use the one thats already there
2. If I already have it defined, how can I set the params above to use THAT venue name / id instead of defining it like above?
Thanks!February 11, 2014 at 8:47 am #103231Barry
MemberHi, great questions!
For the first issue (of detecting an existing venue with a given name), perhaps you could simply achieve this with a custom query? A successful result will yield the post ID. For the second issue, the following information might clarify things:
Note: If ONLY the ‘VenueID’/’OrganizerID’ value is set in the ‘Venue’/’Organizer’ array, then the specified Venue/Organizer will be associated with this Event without attempting to edit the Venue/Organizer. If NO ‘VenueID’/’OrganizerID’ is passed, but other Venue/Organizer data is passed, then a new Venue/Organizer will be created.
Does that help?
February 14, 2014 at 5:47 am #104444efromdc
ParticipantI actually implemented this a few hours before you replied:
$venueQuery = get_page_by_title( $venue, OBJECT, ‘tribe_venue’ );
if ($venueQuery) {
update_post_meta( $postID, ‘_EventVenueID’, $venueQuery->ID; );
}
else {
$venueData = array();
$venueData[‘Venue’] = $name
$venueData[‘post_type’] = ‘tribe_venue’;
$venueData[‘Country’] = $country;
$venueData[‘Address’] = $street;
$venueData[‘City’] = $city;
$venueData[‘State’] = $state;
$venueData[‘Zip’] = $zip;
$venueData[‘ShowMap’] = true;
$venueData[‘ShowMapLink’] = true;
$venueData[‘Phone’] = $phone;
$venueData[‘URL’] = $url;
$event[‘Venue’]=$venueData;February 14, 2014 at 3:58 pm #104767Barry
MemberExcellent!
-
AuthorPosts
- The topic ‘(Solved) How can I set a pre-defined venue via php?’ is closed to new replies.
