Tribe__Events__Organizer::update( $id, array $data )

Updates an organizer


Parameters

$organizerId

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

$data

(array) (Required) The organizer data.


Top ↑

Return

(int) The updated organizer post ID


Top ↑

Source

File: src/Tribe/Organizer.php

	public function update( $id, $data ) {
		/**
		 * Filters the ID of the organizer before the class updates it.
		 *
		 * If a non `null` value is returned that will be returned and the organizer update process will bail.
		 *
		 * @param mixed $check        Whether the organizer update process should proceed or not.
		 * @param int   $organizer_id The post ID of the organizer that should be updated
		 * @param array $data         The data provided to update the organizer.
		 *
		 * @since 4.6
		 */
		$check = apply_filters( 'tribe_events_tribe_organizer_update', null, $id, $data );

		if ( null !== $check ) {
			return $check;
		}

		$data = new Tribe__Data( $data, '' );

		unset( $data['OrganizerID'] );

		$args = array_filter( array(
			'ID'            => $id,
			'post_title'    => Tribe__Utils__Array::get( $data, 'post_title', $data['Organizer'] ),
			'post_content'  => Tribe__Utils__Array::get( $data, 'post_content', $data['Description'] ),
			'post_excerpt'  => Tribe__Utils__Array::get( $data, 'post_excerpt', $data['Excerpt'] ),
			'post_author'   => $data['post_author'],
			'post_date'     => $data['post_date'],
			'post_date_gmt' => $data['post_date_gmt'],
			'post_status'   => $data['post_status'],
		) );

		if ( count( $args ) > 1 ) {
			$post_type = Tribe__Events__Main::ORGANIZER_POST_TYPE;
			$tag       = "save_post_{$post_type}";
			remove_action( $tag, array( tribe( 'tec.main' ), 'save_organizer_data' ), 16 );
			wp_update_post( $args );
			add_action( $tag, array( tribe( 'tec.main' ), 'save_organizer_data' ), 16, 2 );
		}

		$post_fields = array_merge( Tribe__Duplicate__Post::$post_table_columns, array(
			'Organizer',
			'Description',
			'Excerpt',
		) );
		$meta = array_diff_key( $data->to_array(), array_combine( $post_fields, $post_fields ) );

		$this->save_meta( $id, $meta );

		/**
		 * Fires immediately after an organizer has been updated.
		 *
		 * @param int $organizer_id The updated organizer post ID.
		 * @param array $data The data used to update the organizer.
		 */
		do_action( 'tribe_events_organizer_updated', $id, $data->to_array() );

		return $id;
	}

Top ↑

Changelog

Changelog
Version Description
4.6 Introduced.