WordPress.org

Forums

[resolved] [Plugin: Theme my login] Logout URL with trailing slash doesn't complete logout (2 posts)

  1. DanielTulp
    Member
    Posted 2 years ago #

    Using Theme my profile 6.2.2

    When I click the logout hyperlink in the Theme my login users menu in my sidebar, the URL had a trailing slash after my permalink to the login page like: http://www.mysite.com/login/?action=logout&_wpnonce=...
    This seems to be working initially, but when you refresh the page or navigate to another page on the website, you're still logged in.

    I therefor changed 'class-theme-my-login-template.php' in /wp-content/plugins/theme-my-login/includes
    at line 666 from:

    echo '<li><a href="' . wp_logout_url() . '">' . __( 'Log out', 'theme-my-login' ) . '</a></li>' . "\n";

    to:

    function drt_logout_url($redirect = '') {
    	$args = array( 'action' => 'logout' );
    	if ( !empty($redirect) ) {
    		$args['redirect_to'] = urlencode( $redirect );
    	}
    
    	$logout_url = add_query_arg($args, '../login');
    	$logout_url = wp_nonce_url( $logout_url, 'log-out' );
    
    	return apply_filters('logout_url', $logout_url, $redirect);
    }
    echo '<li><a href="' . drt_logout_url() . '">' . __( 'Log out', 'theme-my-login' ) . '</a></li>' . "\n";

    this is basically just a rewrite of the wp_logout_url() function

    hope this helpes someone

    obviously, you need to change '../login' to your own login permalink without trailing slash, didn't bother to add this dynamically

  2. atnjanet
    Member
    Posted 2 years ago #

    Thanks for the tip. I want to follow what you stated above but the version is now 6.3.8, and the line you referred to was altered I think. If I want to implement the code you suggested, where should I put it? And does it still work for the new version?

    Thanks.

Topic Closed

This topic has been closed to new replies.

About this Topic