tribe_create_event( array $args )

Create an Event

$args accepts all the args that can be passed to wp_insert_post(). In addition to that, the following args can be passed specifically for the process of creating an Event:

  • EventStartDate date string (required) – Start date of the Event.
  • EventEndDate date string (required) – End date of the Event.
  • EventAllDay bool – Set to true if event has no start / end time and should run all day.
  • EventStartHour string – Event start hour (01-12 if EventStartMeridian is also passed, else 00-23).
  • EventStartMinute string – Event start minute (00-59).
  • EventStartMeridian string – Event start meridian (am or pm).
  • EventEndHour string – Event end hour (01-12 if EventEndMeridian is also passed, else 00-23).
  • EventEndMinute string – Event end minute (00-59).
  • EventEndMeridian string – Event end meridian (am or pm).
  • EventHideFromUpcoming bool – Set to true to hide this Event from the upcoming list view.
  • EventShowMapLink bool – Set to true to display a link to the map in the Event view.
  • EventShowMap bool – Set to true to embed the map in the Event view.
  • EventCost string – Default cost of the Event.
  • EventURL string – Link to the Event Website or Third-Party page
  • Venue array – Array of data to create or update an Venue to be associated with the Event. tribe_create_venue.
  • Organizer array – Array of data to create or update an Organizer to be associated with the Event. tribe_create_organizer.

Note: If ONLY the ‘VenueID’/’OrganizerID’ value is set in the ‘Venue’/’Organizer’ array, then the specified Venue/Organizer will be associated with this Event without attempting to edit the Venue/Organizer. If NO ‘VenueID’/’OrganizerID’ is passed, but other Venue/Organizer data is passed, then a new Venue/Organizer will be created.

Also note that this function can be used only for the creation of events, supplying a post_type argument therefore is superfluous as it will be reset to the events post type in any case.

See also #

Top ↑

Parameters #


(array) (Required) Elements that make up post to insert.

Top ↑

Return #

(int|bool) ID of the event that was created. False if insert failed.

Top ↑

Source #

File: src/functions/advanced-functions/event.php

	function tribe_create_event( $args ) {
		$args['post_type'] = Tribe__Events__Main::POSTTYPE;
		$postId            = Tribe__Events__API::createEvent( $args );

		return is_wp_error( $postId ) ? false : $postId;