by axew3 » Mon Feb 20, 2017 10:13 am
hi, what happen when you click logout? You're redirected where, instead to be logout?
it is online?
the unique code added is to redirect correctly on user login, and is on
class.wp.w3all-phpbb.php
but it is wrapped inside condition that the user need to be logged-out to fire, so should not affect.
Code: Select all
// REDIRECTION ON WP LOGIN
// correct redirect CHECK if ... $_SERVER['HTTP_REFERER'] is available on this server, if not default to WP home
// check if something wrong on $_SERVER['HTTP_REFERER'], and assign WP home url by default if the case
if(isset($_SERVER['HTTP_REFERER'])){
$wpdomain = preg_replace('/(f|ht)tps?:\/\//', '',get_option('siteurl'));
if(strpos($wpdomain, '/')){ // if not skip
$wpdomain = substr($wpdomain, 0, strpos($wpdomain, '/'));
} else { $wpdomain = $wpdomain; } // else pass as is to check
$purl = utf8_encode(trim($_SERVER['HTTP_REFERER']));
$w3ck = preg_replace('/(f|ht)tps?:\/\//', '',$purl);
if(strpos($w3ck, '/')){ // if not skip
$w3ck = substr($w3ck, 0, strpos($w3ck, '/'));
$uparts = array_reverse(explode('.',$w3ck));
$w3ckdomain = (isset($uparts[1])) ? $uparts[1] . '.' . $uparts[0] : $uparts[0]; // build the real passed domain in URL to be checked
} else { $w3ckdomain = $w3ck; }
} // END correct redirect CHECK if ... $_SERVER['HTTP_REFERER']
// it seem to me perfect, but we will see ;)
if(!stristr($wpdomain,$w3ckdomain) OR !isset($_SERVER['HTTP_REFERER'])){
$_REQUEST['redirect_to'] = get_home_url(); // If no HTTP_REFERER available, there is no correct redirect (in this way): setup here in case, to a default page you want
} else {
$_REQUEST['redirect_to'] = $_SERVER['HTTP_REFERER'];
}
// if it is login page, while adding user, or user will be logged in, but is redirected to wp-login page
if( strpos($_REQUEST['redirect_to'], 'wp-login.php' ) && is_user_logged_in() ){
$_REQUEST['redirect_to'] = admin_url().'profile.php';
}
if ( isset( $_REQUEST['redirect_to'] ) ) {
$redirect_to = $requested_redirect_to = $_REQUEST['redirect_to'];
} else {
$redirect_to = home_url();
$requested_redirect_to = '';
}
$redirect_to = apply_filters( 'login_redirect', $redirect_to, $requested_redirect_to, $current_user );
wp_redirect( $redirect_to );
exit;
}
[EDITED]
hi, what happen when you click logout? You're redirected where, instead to be logout?
it is online?
the unique code added is to redirect correctly on user login, and is on [i]class.wp.w3all-phpbb.php[/i]
[code]class.wp.w3all-phpbb.php[/code]
but it is wrapped inside condition that the user need to be logged-out to fire, so should not affect.
[code] // REDIRECTION ON WP LOGIN
// correct redirect CHECK if ... $_SERVER['HTTP_REFERER'] is available on this server, if not default to WP home
// check if something wrong on $_SERVER['HTTP_REFERER'], and assign WP home url by default if the case
if(isset($_SERVER['HTTP_REFERER'])){
$wpdomain = preg_replace('/(f|ht)tps?:\/\//', '',get_option('siteurl'));
if(strpos($wpdomain, '/')){ // if not skip
$wpdomain = substr($wpdomain, 0, strpos($wpdomain, '/'));
} else { $wpdomain = $wpdomain; } // else pass as is to check
$purl = utf8_encode(trim($_SERVER['HTTP_REFERER']));
$w3ck = preg_replace('/(f|ht)tps?:\/\//', '',$purl);
if(strpos($w3ck, '/')){ // if not skip
$w3ck = substr($w3ck, 0, strpos($w3ck, '/'));
$uparts = array_reverse(explode('.',$w3ck));
$w3ckdomain = (isset($uparts[1])) ? $uparts[1] . '.' . $uparts[0] : $uparts[0]; // build the real passed domain in URL to be checked
} else { $w3ckdomain = $w3ck; }
} // END correct redirect CHECK if ... $_SERVER['HTTP_REFERER']
// it seem to me perfect, but we will see ;)
if(!stristr($wpdomain,$w3ckdomain) OR !isset($_SERVER['HTTP_REFERER'])){
$_REQUEST['redirect_to'] = get_home_url(); // If no HTTP_REFERER available, there is no correct redirect (in this way): setup here in case, to a default page you want
} else {
$_REQUEST['redirect_to'] = $_SERVER['HTTP_REFERER'];
}
// if it is login page, while adding user, or user will be logged in, but is redirected to wp-login page
if( strpos($_REQUEST['redirect_to'], 'wp-login.php' ) && is_user_logged_in() ){
$_REQUEST['redirect_to'] = admin_url().'profile.php';
}
if ( isset( $_REQUEST['redirect_to'] ) ) {
$redirect_to = $requested_redirect_to = $_REQUEST['redirect_to'];
} else {
$redirect_to = home_url();
$requested_redirect_to = '';
}
$redirect_to = apply_filters( 'login_redirect', $redirect_to, $requested_redirect_to, $current_user );
wp_redirect( $redirect_to );
exit;
}[/code]
[EDITED]