tribe_get_organizer_object( null|int|WP_Post $organizer = null, string|null $output = OBJECT, string $filter = 'raw', bool $force = false )

Fetches and returns a decorated post object representing a Organizer.


Parameters

$organizer

(null|int|WP_Post) (Optional) The organizer ID or post object or null to use the global one.

Default value: null

$output

(string|null) (Optional) The required return type. One of OBJECT, ARRAY_A, or ARRAY_N, which correspond to a WP_Post object, an associative array, or a numeric array, respectively. Defaults to OBJECT.

Default value: OBJECT

$filter

(string) (Optional) Type of filter to apply. Accepts 'raw'.

Default value: 'raw'

$force

(bool) (Optional) Whether to force a re-fetch ignoring cached results or not.

Default value: false


Top ↑

Return

(array|mixed|void|WP_Post|null) The Organizer post object or array, null if not found.

  • 'phone'
    (string) The organizer phone number NOT filtered, apply anti-spambot filters if required.
  • 'website'
    (string) The organizer full website URL.
  • 'email'
    (string) The organizer email address NOT filtered, apply anti-spambot filters if required.


Top ↑

Source

File: src/functions/template-tags/organizer.php

	function tribe_get_organizer_object( $organizer = null, $output = OBJECT, $filter = 'raw', $force = false ) {
		/**
		 * Filters the organizer result before any logic applies.
		 *
		 * Returning a non `null` value here will short-circuit the function and return the value.
		 * Note: this value will not be cached and the caching of this value is a duty left to the filtering function.
		 *
		 * @since 5.3.0
		 *
		 * @param mixed       $return      The organizer object to return.
		 * @param mixed       $organizer       The organizer object to fetch.
		 * @param string|null $output      The required return type. One of OBJECT, ARRAY_A, or ARRAY_N, which
		 *                                 correspond to a `WP_Post` object, an associative array, or a numeric array,
		 *                                 respectively. Defaults to `OBJECT`.
		 * @param string      $filter      Type of filter to apply. Accepts 'raw'.
		 */
		$return = apply_filters( 'tribe_get_organizer_object_before', null, $organizer, $output, $filter );

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

		$post = false;
		if ( ! $force ) {
			$cache_key = 'tribe_get_organizer_object_' . md5( json_encode( [ $organizer, $output, $filter ] ) );
			/** @var Tribe__Cache $cache */
			$cache = tribe( 'cache' );
			$post  = $cache->get( $cache_key, Tribe__Cache_Listener::TRIGGER_SAVE_POST );
		}

		if ( false === $post ) {
			$post = Organizer::from_post( $organizer )->to_post( $output, $filter );

			if ( empty( $post ) ) {
				return null;
			}

			/**
			 * Filters the organizer post object before caching it and returning it.
			 *
			 * Note: this value will be cached; as such this filter might not run on each request.
			 * If you need to filter the output value on each call of this function then use the `tribe_get_organizer_object_before`
			 * filter.
			 *
			 * @since 5.3.0
			 *
			 * @param WP_Post $post   The organizer post object, decorated with a set of custom properties.
			 * @param string  $output The output format to use.
			 * @param string  $filter The filter, or context of the fetch.
			 */
			$post = apply_filters( 'tribe_get_organizer_object', $post, $output, $filter );

			$cache->set( $cache_key, $post, WEEK_IN_SECONDS, Tribe__Cache_Listener::TRIGGER_SAVE_POST );
		}

		if ( OBJECT !== $output ) {
			$post = ARRAY_A === $output ? (array) $post : array_values( (array) $post );
		}

		return $post;
	}

Top ↑

Changelog

Changelog
Version Description
5.3.0 Introduced.