bbp_redirect_to_field

Output hidden request URI field for user forms.

Description

bbp_redirect_to_field( (string) $redirect_to = '' ); 

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

Parameters (1)

0. $redirect_to — Optional. (string) => ''
Pass a URL to redirect to

Usage

  1. if ( !function_exists( 'bbp_redirect_to_field' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'bbpress/includes/common/template.php'; 
  3.  
  4. // Pass a URL to redirect to 
  5. $redirect_to = ''; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = bbp_redirect_to_field($redirect_to); 
  9.  

Defined (1)

The function is defined in the following location(s).

/includes/common/template.php  
  1. function bbp_redirect_to_field( $redirect_to = '' ) { 
  2.  
  3. // Make sure we are directing somewhere 
  4. if ( empty( $redirect_to ) ) { 
  5. if ( isset( $_SERVER['REQUEST_URI'] ) ) { 
  6. $redirect_to = ( is_ssl() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; 
  7. } else { 
  8. $redirect_to = wp_get_referer(); 
  9.  
  10. // Remove loggedout query arg if it's there 
  11. $redirect_to = remove_query_arg( 'loggedout', $redirect_to ); 
  12. $redirect_field = '<input type="hidden" id="bbp_redirect_to" name="redirect_to" value="' . esc_url( $redirect_to ) . '" />'; 
  13.  
  14. echo apply_filters( 'bbp_redirect_to_field', $redirect_field, $redirect_to );