tribe_create_event not saving Venue and Organizer

Home Forums Calendar Products Events Calendar PRO tribe_create_event not saving Venue and Organizer

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #1192306
    Morten Arnholtz
    Participant

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

    #1192928
    Cliff
    Member

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

    #1195205
    Morten Arnholtz
    Participant

    So 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

    #1198169
    Morten Arnholtz
    Participant

    Anything yet?

    #1199258
    Brook
    Participant

    Howdy 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

    #1208891
    Support Droid
    Keymaster

    Hey 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

Viewing 6 posts - 1 through 6 (of 6 total)
  • The topic ‘tribe_create_event not saving Venue and Organizer’ is closed to new replies.