Page 1 of 1

WP Log out not working.

Posted: Sun Feb 19, 2017 11:16 pm
by k3v1np
The login now works properly on my site since the latest update. However the logout does not. I have to go to the embedded phpbb page and use the logout from phpbb to actually logout. The widget logout nor the Logout in the Wordpress header bar work.

Re: WP Log out not working.

Posted: Mon Feb 20, 2017 10:13 am
by axew3
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

Code: Select all

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]

Re: WP Log out not working.

Posted: Mon Feb 20, 2017 10:23 am
by axew3
this is the very latest piece added on, that you could try to remove and see what happen in case:
try to REMOVE this:

Code: Select all

          // 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';
         }
let know

[EDITED]