Enable WordPress Auto-Login

March 30th, 2011 Category: WordPress

You may also think that loggin in every time you want to access the admin area of one of your WordPress blogs is quite annoying. But there is a quick way to enable the auto-login for WordPress. It’s shown below.

Add the following lines of code to the functions.php in theme directory:

function auto_login() {
  if (!is_user_logged_in()) {
  //determine WordPress user account to impersonate
  $user_login = 'guest';
 //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');

Source: lbsharp.com

Share and Enjoy:
These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • del.icio.us
  • StumbleUpon
  • Reddit
  • Webnews
  • MisterWong
  • Y!GG
  • Facebook
  • Furl
  • Google Bookmarks
  • Live-MSN
  • Readster
  • YahooMyWeb
This entry was posted on Wednesday, March 30th, 2011 and is filed under WordPress. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

2 Responses to “Enable WordPress Auto-Login”

  1. charly on July 27th, 2011 at 15:45

    hi
    did you test this code?
    this is a code from 2007
    i test it on wp 3
    do not work

    it work for you?

  2. Natarajan on December 29th, 2012 at 09:39

    It’ code is working.

Leave a Reply