Skip to:
Content
Pages
Categories
Search
Top
Bottom

Re: redirect after login error


Sam Bauers
Participant

@sambauers

The only real problem you have is that the Warning is being printed to screen. On a production site you shouldn’t print PHP errors on the screen.

The warning in that case should be dealt with though and I will do so in trunk for 1.0. If you want to modify the bb_safe_redirect() function then use the below code for a plugin to rid you of the warning.

<?php
/*
Plugin Name: Suppress bb_safe_redirect Warnings
Plugin URI:
Description:
Author:
Author URI:
Version: 0.1
*/

function bb_safe_redirect($location, $status = 302) {

// Need to look at the URL the way it will end up in wp_redirect()
$location = wp_sanitize_redirect($location);

// browsers will assume 'http' is your protocol, and will obey a redirect to a URL starting with '//'
if ( substr($location, 0, 2) == '//' )
$location = 'http:' . $location;

$home = bb_get_uri(null, null, BB_URI_CONTEXT_HEADER);

if ( !$lp = @parse_url($location) )
return wp_redirect($home, $status);

$wpp = parse_url(bb_get_uri());

$allowed_hosts = (array) apply_filters('allowed_redirect_hosts', array($wpp['host']), isset($lp['host']) ? $lp['host'] : '');

if ( isset($lp['host']) && !in_array($lp['host'], $allowed_hosts) )
return wp_redirect($home, $status);

return wp_redirect($location, $status);
}
?>

Skip to toolbar