Title: chasecm's Replies | WordPress.org

---

# chasecm

  [  ](https://wordpress.org/support/users/chasecm/)

 *   [Profile](https://wordpress.org/support/users/chasecm/)
 *   [Topics Started](https://wordpress.org/support/users/chasecm/topics/)
 *   [Replies Created](https://wordpress.org/support/users/chasecm/replies/)
 *   [Reviews Written](https://wordpress.org/support/users/chasecm/reviews/)
 *   [Topics Replied To](https://wordpress.org/support/users/chasecm/replied-to/)
 *   [Engagements](https://wordpress.org/support/users/chasecm/engagements/)
 *   [Favorites](https://wordpress.org/support/users/chasecm/favorites/)

 Search replies:

## Forum Replies Created

Viewing 1 replies (of 1 total)

 *   Forum: [Developing with WordPress](https://wordpress.org/support/forum/wp-advanced/)
   
   In reply to: [Automatically authenticate users in wp-admin](https://wordpress.org/support/topic/automatically-authenticate-users-in-wp-admin/)
 *  [chasecm](https://wordpress.org/support/users/chasecm/)
 * (@chasecm)
 * [8 years, 8 months ago](https://wordpress.org/support/topic/automatically-authenticate-users-in-wp-admin/#post-9463029)
 * This is exactly how we login a user automatically, at any role, maybe it will
   help.
 *     ```
       function autoLogin( $user ) {
               if (!$user = get_user_by('login', $user)) {
                       echo __LINE__;
                       return;
               }
               wp_set_current_user( $user->data->ID, $user->data->user_login);
               wp_set_auth_cookie( $user->data->ID );
               do_action( 'wp_login', $user->data->user_login );
               header( 'Location: '.site_url());
       }
       ```
   
    -  This reply was modified 8 years, 8 months ago by [bcworkz](https://wordpress.org/support/users/bcworkz/).
      Reason: code fixed

Viewing 1 replies (of 1 total)