bbp_redirect_to_field( string $redirect_to = '' )

Output hidden request URI field for user forms.


Description Description

The referer link is the current Request URI from the server super global. To check the field manually, use bbp_get_redirect_to().


Parameters Parameters

$redirect_to

(Optional) Pass a URL to redirect to

Default value: ''


Top ↑

Source Source

File: includes/common/template.php

function bbp_redirect_to_field( $redirect_to = '' ) {

	// Make sure we are directing somewhere
	if ( empty( $redirect_to ) ) {
		if ( isset( $_SERVER['REQUEST_URI'] ) ) {
			$redirect_to = bbp_get_url_scheme() . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
		} else {
			$redirect_to = wp_get_referer();
		}
	}

	// Remove loggedout query arg if it's there
	$redirect_to    = remove_query_arg( 'loggedout', $redirect_to );
	$redirect_field = '<input type="hidden" id="bbp_redirect_to" name="redirect_to" value="' . esc_url( $redirect_to ) . '" />';

	// Filter & return
	echo apply_filters( 'bbp_redirect_to_field', $redirect_field, $redirect_to );
}

Top ↑

Changelog Changelog

Changelog
Version Description
2.0.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

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