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?
- how to know if admin is in edit page or post [duplicate]
- The website cannot display the page
- Set Default Admin Colour For All Users
- Settings API – easiest way of validating checkboxes?
- Uploading files in admin panel?
- Redirect Admin User in Dashboard
- Read only capability for custom post in admin area
- How can ‘admin_email’ be set?
- How to change WordPress default strings?
- How to customize wordpress login/register pages?
- Remove ability to access certain admin menus
- Gutenberg “Add Block” button is not active (greyed out), cannot add new blocks
- Hide update messages from non-admin users?
- “Automatically add new top-level pages” Default
- Check if user is logged in else login page
- Is there a way to have admins that are logged in to wordpress not have to enter the password for password protected pages while browsing the website?
- Include admins in author drop-down on edit post screen
- How to restrict wp-admin and prevent upload errors
- Adding another “Add Post” button to admin
- What determines whether admin toolbar is shown to a logged-in user?
- Adding text in more than one language (at the same time)
- How to get view count of every page on site and add that (increasing) number to Dashboard Widget
- Restrict function call to page load but not ajax call
- How do I remove All and Published if not admin?
- How to disable https from wordpress site?
- Fatal error: Exception thrown without a stack frame in Unknown on line 0
- Apply permissions per post
- Settings API not saving values to database
- Dashboard menu missing
- Unable to upload image using the standard uploader in the WP admin (v4.3)
- Featured image on post edit page not loading over HTTPS
- Post editor is 89953px tall. How to fix?
- How to make sure your admin doesn’t hi-jack you site?
- Admin bar is disabled in front
- Load stylesheet on custom admin submenu page
- Add JavaScript in admin in custom plugin [duplicate]
- How can all E-mails be sent with BCC copy to Admin?
- Error 404 Display on otherlinks apart from homepage
- How to change the title attribute for the WP logo image on wp-login.php
- site admin for subscribers
- WordPress gallery image link gives 404 when not logged in
- Custom Div with links on Admin Bar
- WordPress admin loads erratically “connection reset by peer”
- Remove “minor-publishing” div from Publish admin metabox
- You do not have permission to access this document on form submit
- Modify ‘the_content’ appearance in the admin area