wp_referer_field( bool $display = true ): string

Retrieves or displays referer hidden field for forms.


Description

The referer link is the current Request URI from the server super global. The input name is ‘_wp_http_referer’, in case you wanted to check manually.


Top ↑

Parameters

$display bool Optional
Whether to echo or return the referer field.

Default: true


Top ↑

Return

string Referer field HTML markup.


Top ↑

Source

File: wp-includes/functions.php. View all references

function wp_referer_field( $display = true ) {
	$request_url   = remove_query_arg( '_wp_http_referer' );
	$referer_field = '<input type="hidden" name="_wp_http_referer" value="' . esc_url( $request_url ) . '" />';

	if ( $display ) {
		echo $referer_field;
	}

	return $referer_field;
}


Top ↑

Changelog

Changelog
Version Description
2.0.4 Introduced.

Top ↑

User Contributed Notes

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