wpmu_admin_do_redirect( string $url =  )

This function has been deprecated. Use wp_redirect() instead.

Redirect a user based on $_GET or $_POST arguments.

Description

The function looks for redirect arguments in the following order: 1) $_GET[‘ref’] 2) $_POST[‘ref’] 3) $_SERVER[‘HTTP_REFERER’] 4) $_GET[‘redirect’] 5) $_POST[‘redirect’] 6) $url

See also

Parameters

$urlstringoptional
Redirect URL.

Default:''

Source

function wpmu_admin_do_redirect( $url = '' ) {
	_deprecated_function( __FUNCTION__, '3.3.0', 'wp_redirect()' );

	$ref = '';
	if ( isset( $_GET['ref'] ) && isset( $_POST['ref'] ) && $_GET['ref'] !== $_POST['ref'] ) {
		wp_die( __( 'A variable mismatch has been detected.' ), __( 'Sorry, you are not allowed to view this item.' ), 400 );
	} elseif ( isset( $_POST['ref'] ) ) {
		$ref = $_POST['ref'];
	} elseif ( isset( $_GET['ref'] ) ) {
		$ref = $_GET['ref'];
	}

	if ( $ref ) {
		$ref = wpmu_admin_redirect_add_updated_param( $ref );
		wp_redirect( $ref );
		exit;
	}
	if ( ! empty( $_SERVER['HTTP_REFERER'] ) ) {
		wp_redirect( $_SERVER['HTTP_REFERER'] );
		exit;
	}

	$url = wpmu_admin_redirect_add_updated_param( $url );
	if ( isset( $_GET['redirect'] ) && isset( $_POST['redirect'] ) && $_GET['redirect'] !== $_POST['redirect'] ) {
		wp_die( __( 'A variable mismatch has been detected.' ), __( 'Sorry, you are not allowed to view this item.' ), 400 );
	} elseif ( isset( $_GET['redirect'] ) ) {
		if ( str_starts_with( $_GET['redirect'], 's_' ) )
			$url .= '&action=blogs&s='. esc_html( substr( $_GET['redirect'], 2 ) );
	} elseif ( isset( $_POST['redirect'] ) ) {
		$url = wpmu_admin_redirect_add_updated_param( $_POST['redirect'] );
	}
	wp_redirect( $url );
	exit;
}

Changelog

VersionDescription
3.3.0Use wp_redirect()
MU (3.0.0)Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.