Home › Forums › Calendar Products › Events Calendar PRO › Example use of tribe_create_event ?
- This topic has 4 replies, 3 voices, and was last updated 10 years, 9 months ago by
Support Droid.
-
AuthorPosts
-
November 26, 2011 at 7:13 am #11492
Mathieu
ParticipantHi!
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!November 30, 2011 at 2:04 pm #11551Jonah
ParticipantHi 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
November 30, 2011 at 11:56 pm #11590Mathieu
ParticipantThanks!
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!
December 1, 2011 at 5:05 pm #11623Jonah
ParticipantYou’re welcome. Yes, the event would be duplicated. But you could use tribe_update_event to update instead.
July 2, 2015 at 7:33 am #974673Support Droid
KeymasterThis 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. -
AuthorPosts
- The topic ‘Example use of tribe_create_event ?’ is closed to new replies.
