Tribe__Events__API::updateEvent( int $event_id, array $args )

Update an existing event


Parameters

$event_id

(int) (Required) The event ID to update.

$args

(array) (Required) The post args.


Top ↑

Return

(int|WP_Error) The updated event ID or a WP_Error object if it fails.


Top ↑

Source

File: src/Tribe/API.php

		public static function updateEvent( $event_id, $args ) {
			$event_id          = absint( $event_id );
			$post              = get_post( $event_id );
			$args['ID']        = $event_id;
			$args['post_type'] = Tribe__Events__Main::POSTTYPE;

			// allow for the change of the date and the status in the same update request
			if (
				isset( $args['post_date'], $args['post_status'] )
				&& in_array( $post->post_status, array( 'draft', 'pending', 'auto-draft' ) )
				&& $args['post_status'] !== $post->post_status
			) {
				$args['edit_date'] = true;
			}

			$args = self::sanitize_event_post_create_update_args( $args );
			if ( is_wp_error( $args ) ) {
				return $args;
			}

			if ( wp_update_post( $args ) ) {
				self::saveEventMeta( $event_id, $args, $post );
			}

			return $event_id;
		}