Forums

[resolved] log user out (6 posts)

  1. mercuryfenix
    Member
    Posted 3 years ago #

    I would like to log the user out and redirect to the home page instead of ending up on the wp-login page. Is this possible? How?

    Thanks!

  2. mercuryfenix
    Member
    Posted 3 years ago #

    bump

  3. t31os
    Member
    Posted 3 years ago #

    Not without modding core files no, or at least not with ease.

    wp-login.php

    Starting line 274...

    case 'logout' :
    	check_admin_referer('log-out');
    	wp_logout();
    
    	$redirect_to = 'wp-login.php?loggedout=true';
    	if ( isset( $_REQUEST['redirect_to'] ) )
    		$redirect_to = $_REQUEST['redirect_to'];
    
    	wp_safe_redirect($redirect_to);
    	exit();
    
    break;

    You could modify the redirect, but you'll have to do this with each update of WordPress.

  4. mercuryfenix
    Member
    Posted 3 years ago #

    that will have to do. its not too hard. it would be ideal to make a parameter in the loginout function to send it to this...

  5. fUzZy89
    Member
    Posted 3 years ago #

    Before this code worked:

    <a href="<?php bloginfo('url') ?>/wp-login.php?action=logout&amp;redirect_to=<?php echo urlencode($_SERVER['REQUEST_URI']) ?>">Logg ut</a>

    I tried this now, but it does not work anymore, why?

  6. MichaelH
    Volunteer
    Posted 3 years ago #

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags