tribe_get_request_var( string|array $var, mixed $default = null )

Tests to see if the requested variable is set either as a post field or as a URL param and returns the value if so.

Post data takes priority over fields passed in the URL query. If the field is not set then $default (null unless a different value is specified) will be returned.

The variable being tested for can be an array if you wish to find a nested value.

See also


Top ↑

Parameters

$var

(string|array) (Required)

$default

(mixed) (Optional)

Default value: null


Top ↑

Return

(mixed)


Top ↑

Source

File: src/functions/utils.php

	function tribe_get_request_var( $var, $default = null ) {
		$post_var = Tribe__Utils__Array::get( $_POST, $var );

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

		$query_var = Tribe__Utils__Array::get( $_GET, $var );

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

		return $default;
	}

Top ↑

Changelog

Changelog
Version Description
4.9.17 Introduced.