What you have should work – although you should not use $_SESSION
(as Tom already noted). Also ID, user_pass, and user_login are all top level in the user object.
Here’s what I would try:
$email = sanitize_email( $_POST['email'] );
$pass = $_POST['password'];
$user = get_user_by( 'email', $email );
if ( wp_check_password( $pass, $user->user_pass, $user->ID ) ) {
wp_set_current_user( $user->ID );
wp_set_auth_cookie( $user->ID );
do_action( 'wp_login', $user->user_login );
wp_safe_redirect( wp_get_referer() );
exit();
}
Related Posts:
- How to Change the Default Home Page for the WordPress Dashboard?
- is_admin() returns true when using admin-ajax.php from front end script
- Are there any action like ‘init_frontend’
- Cannot access admin panel
- front end logo upload like happytables
- Conditional check for front-end which includes ajax
- Daily notices of failed login attempts for non-existent admin user
- Setting Login with User Name and Password default option for Jetpack Admin Login
- I keep getting logged out in Firefox
- Error thrown. Cannot create references to/from string offsets
- How to determine if an admin is logged in outside the loop
- front end editing using iFrames, best approach?
- Unable to login, old site with previous developer gone
- WordPress Frontend Check If Current User Is Administrator
- Using shared SSL for login/admin
- wp-login behind nginx reverse-proxy inaccessible — bad redirect?
- Can’t access dashboard as administrator, login as any other level works though
- WordPress Admin Login Redirect Problem
- Unable to Access WP Admin or Login buttons after Migration
- using rewrites to secure login page
- Client system for media review?
- How to disable accessing the custom post types from frontend via a link?
- WordPress administration Over SSL – To Force SSL Logins and SSL Admin Access
- Keep Logged in Users out of Admin Panel
- Unable to get to the admin panel
- I can’t access the login panel on my offline website
- Admin login not working
- Can’t login to my admin area
- Does deleting the table users prevent all logins?
- Locked out of WordPress website from wrong amount of login attempts
- current_user_can(‘administrator’) not working in custom login
- Send admin to a different login than users?
- Want to know who is login Admin/User
- Remove iPhone detection on login page
- Any known plugins for master admin login to edit all on front end?
- How to show WordPress admin dashboard forms on front-end?
- Error “Sorry, you are not allowed to access this page”
- I can’t access login page
- Can you check if https is enabled on frontend from admin
- Admins loggin in to our wordpress site default to the admin page
- Disabling “View” mentions from backend?
- WordPress login not working
- Login to Admin Dashboard Problem
- WordPress login process is hanging
- WordPress “Hide WP” Gives Me Error After Admin Login [closed]
- Editing post in admin panel
- Scripts are not called until I login from wordpress backend
- Disable wp-admin log on lightbox overlay
- Lock Display Name To Nickname
- How to cancel redirection to admin side
- Can’t access my wp admin: captcha images invisible, gives me error message
- 2FA for admin login only, is it doable?
- 500 error for regular users, not for admin
- What are the standard admin CSS id/class tags?
- Admin Ajax is returning 0
- Add custom column to Users admin panel
- wp_verify_nonce vs check_admin_referer
- Add a Separator to the Admin Menu?
- How to determine whether we are in add New page/post/CPT or in edit page/post/CPT in wordpress admin?
- how to know if admin is in edit page or post [duplicate]
- Modal window from within WordPress admin
- Where in WP can I check history or log of updates of plugins etc?
- Adding a custom admin page
- How does admin-ajax.php work?
- How to remove entire admin menu?
- How do I remove dashboard access from specific user roles?
- How can I speed up my WP admin section?
- How to pass parameters to admin_notices?
- Admin: very slow edit page caused by core meta query
- if admin is logged in
- Search posts by ID in admin
- Setting admin edit panels & metaboxes positions and visibility for ALL users and admins
- Find out which moderator approved comment?
- The website cannot display the page
- How To Remove WordPress Version From The Admin Footer
- Sort pages in loop by admin’s page attributes order field?
- Edit “thank you for creating with WordPress” in version 3.3.1
- Hide other users’ posts in admin panel
- Set Default Admin Colour For All Users
- Editor Styles and Typekit
- How to show ‘login error’ and ‘lost password’ on my template page?
- WordPress admin stylesheet
- This CSS Stuffing Works, But Is This A Good Practice?
- Is it possible to create a WordPress tour? V3.3.1
- Securing Admin Accounts – Username Discovery
- How to save dismissable notice state in WP 4.2?
- How do I optimize a custom post type admin page with 25,000 posts?
- Settings API – adding setting fields dynamically?
- Disable Media Uploads to non Admin Users
- How do I load a CSS style into WordPress admin area only?
- Allowing admin-ajax.php to receive “application/json” instead of “x-www-form-urlencoded”
- Can an admin check passwords of registered users?
- How can I target WordPress 3.8 new interface MP6 with CSS?
- Redirect user using the ‘wp_login_failed’ action hook if the error is ’empty_username’ or ’empty_password’
- Notification that the admin is online
- Does wordpress create activity, update logs?
- sort child pages on admin
- How-to make the admin area mobile friendly [closed]
- How to remove list view from media library?
- How to disable the “Your site has updated to WordPress x.y.z” admin email?