Example use of tribe_create_event ?

Home Forums Calendar Products Events Calendar PRO Example use of tribe_create_event ?

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #11492
    Mathieu
    Participant

    Hi!
    Everything is in the title 🙂
    Can someone give an example on how to use correctly the tribe_create_event function please?
    And one additional question, do i have to check if the venue/organizer already exist to provide only the ID in this function, or if i always pass the exactly same information to the function, if there is a venue/organizer with the same data, this one will be used and a new one won’t be created?
    Thanks a lot!

    #11551
    Jonah
    Participant

    Hi Mathieu,

    Here is an example of creating an event with the function and creating a new venue and organizer:

    [php]
    // Create post object
    $my_post = array(
    ‘post_title’ => ‘My post’,
    ‘post_content’ => ‘This is my post.’,
    ‘post_status’ => ‘publish’,
    ‘post_author’ => 1,
    ‘EventStartDate’ => ”,
    ‘EventEndDate’ => ”,
    ‘EventStartHour’ => ‘2’,
    ‘EventStartMinute’ => ’29’,
    ‘EventStartMeridian’ => ‘pm’,
    ‘EventEndHour’ => ‘4’,
    ‘EventEndMinute’ => ’20’,
    ‘EventEndMeridian’ => ‘pm’,
    ‘Venue’ => array(
    ‘Venue’ => ‘test’,
    ‘Country’ => ‘US’,
    ‘Address’ => ‘1 W. Washington Ave.’,
    ‘City’ => ‘Madison’,
    ‘State’ => ‘WI’
    ),
    ‘Organizer’ => array(
    ‘Organizer’ => ‘Jonah West’,
    ‘Email’ => ‘[email protected]
    )
    );

    // Insert the post into the database
    tribe_create_event( $my_post );
    [/php]

    You can also map to an existing venue and/or organizer by simply using the same name of an existing venue or organizer.

    There are more options that you can pass too as documented here:
    https://theeventscalendar.com/support/documentation/the-events-calendar-advanced-functions-event-post-type/

    You can also pass the same args that can be passed to the native WP function wp_insert_post: http://codex.wordpress.org/Function_Reference/wp_insert_post

    – Jonah

    #11590
    Mathieu
    Participant

    Thanks!

    So if i understand, for the venue/organizer part, if an orga like:
    ‘Organizer’ => array(

    ‘Organizer’ => ‘Jonah West’,

    ‘Email’ => ‘[email protected]

    )
    already exists in the db, and that i had another event with the exactly same data, the event will be duplicated right?

    Thanks again!

    #11623
    Jonah
    Participant

    You’re welcome. Yes, the event would be duplicated. But you could use tribe_update_event to update instead.

    #974673
    Support Droid
    Keymaster

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

Viewing 5 posts - 1 through 5 (of 5 total)
  • The topic ‘Example use of tribe_create_event ?’ is closed to new replies.