WordPress.org

Support

Support » Plugins and Hacks » Automatically Log In to WordPress (passing login variables)

Automatically Log In to WordPress (passing login variables)

Viewing 3 replies - 1 through 3 (of 3 total)
  • Just found this!

    http://www.lbsharp.com/wordpress/index.php/2007/12/10/wordpress-auto-login/

    The post is 5 years old but still works perfectly in 3.2.1.

    hmm stuck after all….

    I want to pull the username from the URL using $_GET, but when replacing the string ‘admin’ with the same string ‘admin’ from my $_GET variable, it doesn’t work. Very strange… I know I must be missing something.

    function auto_login() {
    // this works perfectly
    $user_login = ‘admin’;

    // this does not work even when setting the same variable via query string ?user=admin
    // $user_login = $_GET[‘user’];

    //get user’s ID
    $user = get_userdatabylogin($user_login);
    $user_id = $user->ID;

    //login
    wp_set_current_user($user_id, $user_login);
    wp_set_auth_cookie($user_id);
    do_action(‘wp_login’, $user_login);
    }
    add_action(‘init’, ‘auto_login’);

    Hello,
    Did you end up finding the solution for this?
    Best,
    c.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Automatically Log In to WordPress (passing login variables)’ is closed to new replies.
Skip to toolbar