Home › Forums › Calendar Products › Events Calendar PRO › tribe_create_event not saving Venue and Organizer
- This topic has 6 replies, 5 voices, and was last updated 9 years, 4 months ago by
Morten Arnholtz.
-
AuthorPosts
-
November 15, 2016 at 1:30 am #1192306
Morten Arnholtz
ParticipantHi there,
I’ve been using tribe_create_event to manually create events in an ajax action based on user input. It has been working fine until recently. Now neither venues or organizers are saved.
// [.....] $venue = [ 'Venue' => $_POST['event-venue-name'], 'Country' => __('Denmark', 'the-events-calendar'), 'Address' => $_POST['event-venue-address'], 'City' => $_POST['event-venue-city'], 'Zip' => $_POST['event-venue-zip'], 'URL' => $_POST['event-venue-website'], ]; $organizer = [ 'Organizer' => $_POST['event-organizer-name'], 'Email' => $_POST['event-organizer-email'], 'Website' => $_POST['event-organizer-website'], 'Phone' => $_POST['event-organizer-phone'], ]; $args = [ 'post_status' => 'pending', 'post_author' => 1, 'post_title' => $title, 'post_excerpt' => substr( $description, 0, 150 ), 'EventStartDate' => $start_date, 'EventEndDate' => $end_date, 'EventAllDay' => $all_day, 'Venue' => $venue, 'Organizer' => $organizer, 'EventURL' => $website ]; if( ! $all_day ){ $args['EventStartHour'] = $start_hour; $args['EventStartMinute'] = $start_minute; $args['EventEndHour'] = $end_hour; $args['EventEndMinute'] = $end_minute; } // Create the event $event_id = tribe_create_event( $args );The event is created fine, but no venues or organizers are created nor referenced in the event. The issue seems to go away when I’m logged into wordpress.
I’ve managed to work around it by manually creating the venue and organizer using tribe_create_venue and tribe_create_organizer respectively, and then adding EventOrganizerID and EventVenueID to $args. This still feels hacky and keeps me wondering, if something else is wrong.
November 15, 2016 at 8:02 pm #1192928Cliff
MemberHi Morten.
It sounds like the way you’re doing it now matches the current code base. And I didn’t think it sounded hacky. 🙂
https://github.com/moderntribe/the-events-calendar/blob/4.3.2/src/Tribe/API.php#L43Â doesn’t seem to take Organizer / Venue data into account so you doing it yourself sounds correct.
Please let me know if you have any follow-up questions on this topic.
November 21, 2016 at 1:03 am #1195205Morten Arnholtz
ParticipantSo are you saying that the functionality has changed? The former approach has worked until recently, and I find it strange that it works when logged in to wordpress and that the documentation (https://theeventscalendar.com/function/tribe_create_event/) does not reflect any changes.
Also it seems that the linked posts are handled in the saveEventMeta-function:
https://github.com/moderntribe/the-events-calendar/blob/4.3.2/src/Tribe/API.php#L122
-
This reply was modified 9 years, 5 months ago by
Morten Arnholtz.
November 28, 2016 at 2:58 am #1198169Morten Arnholtz
ParticipantAnything yet?
November 29, 2016 at 10:15 am #1199258Brook
ParticipantHowdy Morten,
Sorry for the delay, there was a major holiday in our neck of the woods.
A little bit back things were altered to allow more “linked post types” besides just organizers and venues. This was done for people who wanted to add things like an “author” post type in addition or besides the default ones.
A side effect of this would be that our plugin now always honors the post type’s “create_posts” capability. If a logged out user does not have the capability create posts, then they will not be able to create a venue or organizers. You can of course edit each roles capabilities though, including logged out users. You can do this with the WordPress API, or by using a plugin like User Role Editor. Just find those two post types and modify the create_events capability to  be included in all roles.
Does that all make sense? Did that do the trick?
Cheers!
– Brook
December 21, 2016 at 8:35 am #1208891Support Droid
KeymasterHey there! This thread has been pretty quiet for the last three weeks, so we’re going to go ahead and close it to avoid confusion with other topics. If you’re still looking for help with this, please do open a new thread, reference this one and we’d be more than happy to continue the conversation over there.
Thanks so much!
The Events Calendar Support Team -
This reply was modified 9 years, 5 months ago by
-
AuthorPosts
- The topic ‘tribe_create_event not saving Venue and Organizer’ is closed to new replies.
