tribe_create_event( array $args )

Create’s an Event.

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 #

$args

(array) (Required) An array of elements that make up a post to update or insert. Accepts anything from wp_insert_post().

  • 'ID'
    (int) The post ID. If equal to something other than 0, the post with that ID will be updated. Default 0.
  • 'post_author'
    (int) The ID of the user who added the post. Default is the current user ID.
  • 'post_date'
    (string) The date of the post. Default is the current time.
  • 'post_date_gmt'
    (string) The date of the post in the GMT timezone. Default is the value of $post_date.
  • 'post_content'
    (mixed) The post content. Default empty.
  • 'post_content_filtered'
    (string) The filtered post content. Default empty.
  • 'post_title'
    (string) The post title. Default empty.
  • 'post_excerpt'
    (string) The post excerpt. Default empty.
  • 'post_status'
    (string) The post status. Default 'draft'.
  • 'post_type'
    (string) The post type. Default 'post'.
  • 'comment_status'
    (string) Whether the post can accept comments. Accepts 'open' or 'closed'. Default is the value of 'default_comment_status' option.
  • 'ping_status'
    (string) Whether the post can accept pings. Accepts 'open' or 'closed'. Default is the value of 'default_ping_status' option.
  • 'post_password'
    (string) The password to access the post. Default empty.
  • 'post_name'
    (string) The post name. Default is the sanitized post title when creating a new post.
  • 'to_ping'
    (string) Space or carriage return-separated list of URLs to ping. Default empty.
  • 'pinged'
    (string) Space or carriage return-separated list of URLs that have been pinged. Default empty.
  • 'post_modified'
    (string) The date when the post was last modified. Default is the current time.
  • 'post_modified_gmt'
    (string) The date when the post was last modified in the GMT timezone. Default is the current time.
  • 'post_parent'
    (int) Set this for the post it belongs to, if any. Default 0.
  • 'menu_order'
    (int) The order the post should be displayed in. Default 0.
  • 'post_mime_type'
    (string) The mime type of the post. Default empty.
  • 'guid'
    (string) Global Unique ID for referencing the post. Default empty.
  • 'post_category'
    (array) Array of category IDs. Defaults to value of the 'default_category' option.
  • 'tags_input'
    (array) Array of tag names, slugs, or IDs. Default empty.
  • 'tax_input'
    (array) Array of taxonomy terms keyed by their taxonomy name. Default empty.
  • 'meta_input'
    (array) Array of post meta values keyed by their post meta key. Default empty.
  • 'EventStartDate'
    (string) Start date of event (required).
  • 'EventEndDate'
    (string) End date of event (required).
  • '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'
    (string) 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.
  • 'FeaturedImage'
    (string) URL or ID of a featured image.
  • 'Venue'
    (string) Array of data to create or update an Venue to be associated with the Event tribe_create_venue.
  • 'Organizer'
    (string) Array of data to create or update an Organizer to be associated with the Event tribe_create_organizer.
  • '_ecp*custom*[ID]'
    (string) Pro Custom fields (Events Calendar Pro only).


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;
	}