I found the solution for using below function:
function auto_login() {
// make sure user is not logged in and "user" was POST'd
$username = isset( $_POST['user'] )? $_POST['user'] : false;
if ( ! is_user_logged_in() && $username ){
// load the user by username
$user = get_user_by( 'login', $username );
if ( $user ) {
// log user in using the $user object properties
wp_set_current_user( $user->ID, $user->user_login );
wp_set_auth_cookie( $user->ID );
do_action( 'wp_login', $user->user_login );
}
}
}
add_action( 'wp_loaded','auto_login' );
Related Posts:
- Can I programmatically login a user without a password?
- What is $interim_login?
- Adding extra authentication field in login page
- What exactly is ReAuth?
- Login members using web services
- Disable WordPress 3.6 idle logout / login modal window / session expiration
- How to pass users back and forth using session data?
- Need to execute a cron job
- how to update current logged user username
- Validate Custom Login field
- Calling wp_signon doesn’t log the user in
- How to implement Google reCaptcha without installing a plugin?
- Is it possible a one click user registration with Facebook or Twitter (or other Social Networks)?
- Are there ways of logging in that bypass wp-login.php altogether?
- How to display username and password after registration
- Two factor authentication
- How to generate “WP_Error” Object for user login?
- Allow Access to Home Page and Login Screen but Nothing Else (unless logged in)
- Where is the php file, that does the checks for login information?
- I want login using email not username wordpress front end
- Reloading page with a query string upon login for admins
- WordPress authentication using custom php?
- authenticate user without redirecting
- Multiple issues with Ajax login function due to browsers and cookies
- How to post frontend login form to a different authentication script from wp-login?
- Custom user roles are unable to login
- Using WordPress login for a non word-press website
- Extend Cookie with auth_cookie_expiration not working
- Opening protected page with cookie?
- Handle POST request sent from an external site for login?
- External Authentication
- Login and register by API
- How to login with email only no username?
- Removing username from the ‘wordpress_logged_in’ cookie
- Is it possible to sign in with user_email in WordPress?
- How to use current_user_can()?
- WordPress registration message
- How can I create a separate blog that is private?
- How to customise wp-login.php only for users who are setting a password for the first time?
- Remove built in wordpress login and use only google auth
- Websites defaced by uploading script using theme editor
- I am not able to login to my wp-admin panel
- Block Logged-Out User Access to Directory Outside of WordPress using .htaccess and PHP file
- how to logout user on browser tab or window closes
- Integrate WordPress Blog with Moodle LMS
- Making a client page
- Auto login user with link from Mail
- To be able to login as different user
- Add class to input form in login form
- Can’t Login to WordPress, No Data Received Error
- Unable to access website admin page – 500 error – how to change landing page
- how to restrict user login whenever if a user puts on hold by editing wp-login action?
- WordPress/Buddypress login theme function [closed]
- How to use a custom login template and still have it linked to the wp-login.php instead of creating a new page?
- Login again after profile update
- Redirect wp-login
- Show reCaptcha on Custom Frontend Login & Register Form [closed]
- Auto Login After Registration
- Problems with is_user_logged_in() | Function in WP
- Is the login encrypted before it is sent? If so how to do I encrypt it the same way?
- What speaks against using a custom login.php / register.php to wordpress?
- Login fail with no error
- WordPress login doesn’t work when using preview domain
- Prevent Subscriber Role to login
- How to check if user is logged into wordpress on non-wordpress pages
- How to authenticate a user with an external webservice
- Login user using wp_signon and WP_User object
- Log in with email but no password
- Login form not saving values when login incorrect
- I need to find which is the file that checks the DB for correct login (username, password)
- Abnormal activity at url /my-account/add-payment-method/
- Blacklist and Whitelist on login
- URL Restrictions? Need only people who are logged in AND have a specific role (or roles) to access all pages for a site
- How to add custom authentication to wordpress login and register
- The same session information for peer users on two different WordPress servers
- WordPress new version Version 5.3.2, user login not working after upgrade
- How the wordpress login and signup in react native app
- Link Users to external login db
- Change WordPress Login URL to External URL
- User does not exist
- WordPress login is now working, it just refresh the page and nothing happens.
- is_logged_in not working after login
- wp_signon() does not authenticate user guidance needed
- How to login to wordpress via Cpanel
- Redirect to previous page after login
- display last login date in the frontend
- How user should automatically activated and go for login?
- How to lock WordPress front-end with login and password?
- Site is not loading after relogin attempts on SSL
- Disabling the login form and redirect users on logout without headers sent php warning
- Webpage not found upon entering wrong username and password on custom login form?
- User not logged first time I open the homepage
- How to force login after user browses for a few minutes or browses a few pages?
- WordPress Login Box horizontal at the top.
- Advice on setting up private site
- Cannot login with correct username and password anymore
- How to limit user to login only once per session
- Warning-session start errors and cannot login to administer
- make a login system for site visitors
- Log in a user upon password reset?