Forums

[Plugin From Where You Came ] - redirect after login or logout (2 posts)

  1. MichaelH
    Moderator
    Posted 6 months ago #

    Simple, easy, new plugin to redirect you to where you were when you logged in or out.

    Download at http://files.viper007bond.com/wordpress/fromwhereyoucame.zip

    Plugin Name:  From Where You Came
    Version:      1.0.0
    Description:  Makes the "Login" and "Logout" links take you back from where you came.
    Author:       Viper007Bond
    Author URI:   http://www.viper007bond.com/
    
    add_filter( 'loginout', 'fromwhereyoucame' );
    
    function fromwhereyoucame( $link ) {
    	$currenturl = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
    
    	if ( !is_user_logged_in() )
    		$link = str_replace( '">', '?redirect_to=' . urlencode( $currenturl ) . '">', $link );
    	else
    		$link = str_replace( '">', '&redirect_to=' . urlencode( $currenturl ) . '">', $link );
    
    	return $link;
    }
    
    ?>
  2. clicknathan
    Member
    Posted 6 months ago #

    Wicked.

    Any chance you'd know how to make this work for WP 2.0.4?

Reply

You must log in to post.

About this Topic