• Resolved ropelletier

    (@ropelletier)


    So, I have been working on the for about an hour and it does not seem possible to populate the Venue using the tribe_create_event function. I have tried using a simple array, I have tried using the object from tribe_get_venue and tried just using the ID from tribe_get_venue. Nothing works. I am fully expecting the canned response “We are not able to provide much more support for coding, as per our support policy.” but either the function does not work properly or this is a paid feature for some reason. If this is a paid feature, make sure to make a note of this on this page (https://docs.theeventscalendar.com/reference/functions/tribe_create_event/) so someone, like me, does not waste an hour on it, please.

    Otherwise, I really would appreciate and be very grateful for some assistance with this. I removed a bunch of the code, so the logic below won’t make sense, but the gist should be there. The get_venue function passes a string with the name of the location and then return the full object of the venue post. I have tried just returning the ID, the full object, and just the string. None of it works.

    Thank in advance

    function get_venue($location){
        
        $location = explode('\,', $location)[0];
    
        $venues = json_decode(json_encode(tribe_get_venues()), true);
    
        foreach ($venues as $v):
            echo $v['post_title'] . PHP_EOL;
            if ($v['post_title'] == $location):
                $venue = $v;
                break;
            endif;
        endforeach;
        return $venue;
    
    /* Example of returned 
    (
        [ID] => 404
        [post_author] => 1
        [post_date] => 2020-04-07 08:32:29
        [post_date_gmt] => 2020-04-07 08:32:29
        [post_content] => 
        [post_title] => District Middle School
        [post_excerpt] => 
        [post_status] => publish
        [comment_status] => closed
        [ping_status] => closed
        [post_password] => 
        [post_name] => city-hall
        [to_ping] => 
        [pinged] => 
        [post_modified] => 2023-04-28 12:41:50
        [post_modified_gmt] => 2023-04-28 12:41:50
        [post_content_filtered] => 
        [post_parent] => 0
        [guid] => https://intranet.domain.org/?post_type=tribe_venue&p=404
        [menu_order] => 0
        [post_type] => tribe_venue
        [post_mime_type] => 
        [comment_count] => 0
        [filter] => raw
    )
    */
    }
    
    function create_event($e){
        $event = array(
            'post_title' => $e['post_title'],
            'post_content' => $e['post_content'],
            'post_status' => 'publish',
            'post_author' => 1,
            'EventStartDate' => $e['EventStartDate'],
            'EventEndDate' => $e['EventEndDate'],
            'EventStartHour' => $e['EventStartHour'],
            'EventStartMinute' => $e['EventStartMinute'],
            'EventStartMeridian' => $e['EventStartMeridian'],
            'EventEndHour' => $e['EventEndHour'],
            'EventEndMinute' => $e['EventEndMinute'],
            'EventEndMeridian' => $e['EventEndMeridian'],        
            'Venue' => $e['venue']
            /*,
            'Organizer' => array(
                'Organizer' => 'Organizer Name',
                'Email' => '[email protected]'	
            )*/
            );
        
        $result = tribe_create_event( $event );
        
        update_post_meta($result, '_thumbnail_id', '8671');
    
        return $result;
    }
    
    
    $e['venue'] = get_venue($e['location']);
    
    create_event($e);
    
    
    //// Example $e array below. Using just the Venue ID///
    (
        [post_title] => Test Event 2
        [post_content] => description
        [post_status] => publish
        [post_author] => 1
        [EventStartDate] => 2023-05-15
        [EventEndDate] => 2023-05-15
        [EventStartHour] => 09
        [EventStartMinute] => 00
        [EventStartMeridian] => AM
        [EventEndHour] => 10
        [EventEndMinute] => 00
        [EventEndMeridian] => AM
        [Venue] => 404
    )
                
    • This topic was modified 1 year, 10 months ago by ropelletier.
Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Support Darian

    (@d0153)

    Hi @ropelletier

    Thanks for reaching out. Let me help you with this one.

    I tried the same script you’re using, and it is not working on my side as well. Let me share this with the team, and I’ll get back to you once I know more.

    In the meantime, if you have the venue id, then you can use EventVenueID to assign a venue to your event. Like this one:

    tribe_create_event([
        "post_title" => 'Test Event33333',
        "post_content" => 'description',
        "post_status" => 'publish',
        "post_author" => 1,
        "EventStartDate" => '2023-05-15',
        "EventEndDate" => '2023-05-15',
        "EventStartHour" => '09',
        "EventStartMinute" => '00',
        "EventStartMeridian" => 'AM',
        "EventEndHour" => '10',
        "EventEndMinute" => '00',
        "EventEndMeridian" => 'AM',
        "EventVenueID" => 156
    ]);
    Plugin Support Darian

    (@d0153)

    Hi @ropelletier

    This thread has been inactive for a while, so we’ll go ahead and mark it Resolved. Please open a new thread if any other questions arise, and we’d be happy to help.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Venue does not populate when using tribe_create_event’ is closed to new replies.