Your example works correctly. You are checking if password hello
matches hashed hello
– which it naturally does.
Hadn’t thought it through. Your example causes following issue:
- You check if
hello
matches md5 ofhello
(instead of hash from user’s profile). - It does and then WP thinks this is correct, but outdated md5 hash – that must be updated.
- It re-hashes
hello
and updates user with it, locking him out (since his password is nowhello
instead of whatever it was before).
See wp_authenticate_username_password()
function for extensive example, but basic idea is:
$userdata = get_user_by('login', $username);
$result = wp_check_password($password, $userdata->user_pass, $userdata->ID);
Related Posts:
- How to change user password with wp-cli?
- wordpress redirect after password reset
- Loosen/disable password policy
- Password Protect Custom Page
- How can I change the default wordpress password hashing system to something custom?
- If I change the salt keys in my wp-config will all passwords break?
- Conditional to test if post has password protection enabled
- Bypass password protected posts via GET variable
- How to add Wp_error using lostpassword_post hook when validating custom field?
- Create a USERNAME and PASSWORD protected WordPress page
- Why do generated passwords start/end with spaces?
- Safe to store SMTP password in wp-config.php?
- Access code/password only restricts page access, no user registration..?
- Reseting admin password through PHPMyadmin fails
- Check Password Reset Key Not Woking
- Reset password – set minimum length for new password
- Forgot password not working
- wp_hash_password unexpected behaviour
- Password reset message – change the network_home_url( ‘/’ )
- Redirect a password protected page?
- WordPress: force users to change password on first login
- Can’t login to wordpress despite changing password to something known directly in MySQL or using “Password Reset by Email” feature
- Change default recovery link expiration time
- Lost password link redirects to my-account/lost-password/,how to fix it back to default lost password
- Password protect custom template
- Custom password generator for users
- Where is the reset password key stored/generated?
- Password protecting template, secured content not showing if even password is right
- How validate usernames/passwords against WP’s database?
- WordPress reset password returns invalid key
- Password reset bug? – “Sorry, that key does not appear to be valid”
- How to set minimum length and error message for password recovery?
- Why is resetting the WordPress Users password not working?
- post_password_required() not recognizing cookie set with correct password
- How Authentication in wordpress works? wp_authenticate_username_password()
- Password protect the site (without htaccess or membership)
- Password protection for page template
- Custom login form for front-end user as well as admin
- Enable Update button only when password is shown strong
- How to get user password before being encrypted outside the wordpress core once add a new user from dashboard?
- Adding parameters to password reset key
- wp_hash_password create a different hash everytime
- Custom password form allows unlock two posts with the same password
- How to change password
- Generating the password reset link automatically
- Password protect pages – allow more than one password
- Like to store multiple passwords in db table wp_posts field post_password?
- Send password to user instead of reset password link
- Protect Passwords in wp_users with stronger protection than MD5
- Custom form for password protected page
- How to check user’s password?
- What’s the algorithm to verify user password?
- How to change “Reset Password” text on submit button
- Customize retrieve password message
- How to recover password from a user
- WordPress admin creation through phpmyadmin not working
- How to show my wordpress admin username & password?
- Can’t alter $lostpassword_url
- current user’s password check
- How to initiate password reset flow by code
- Change password fields
- lostpassword_redirect filter is not used
- Password Protect or IP to access under development WordPress site otherwise shown a placeholder page
- Password protected sites
- Password-protected page redirecting to frontpage when I enter the password
- 2 accounts under same email preventing me from loging in
- Site only for users authenticated by different PHP application
- wordpress custom password change problem
- Allow all reset password links within the past 24 hours to be valid and accepted
- Set id and password for each post
- I have to reset the admin password each time
- Create Member who can’t be changed
- Automatically change the page password for more than one page
- Sending Reset Password email via Web API
- I can’t recover my password
- $expiration_duration = apply_filters( ‘password_reset_expiration’, DAY_IN_SECONDS );
- Cannot get function.php code to work to remove Lost Password link on live site
- Entering a WP site with a SMS code
- Problem with login / reset password links in users emails
- Lost Password redirect to My Account
- Multiple pages protected by different passwords. Possible to track multiple passwords at a time?
- How do I display the password field on the WordPress user registration screen?
- Not able to log for the first time on a salted WordPress by creating pwd on BD
- Custom page password recovery
- Password Protected Logout Button Not Working
- Is it possible to display newly generated password after wp_generate_password()?
- Password protect wp-login.php
- How do I password protect a page of posts on WordPress?
- Revise my keyword but still cannot login
- WordPress not taking password and username
- Is it possible to have users register without having a password?
- Password Protection for posts and pages [duplicate]
- How WordPress hashes passwords
- Reset Password – change from name and email address. It stucks at admin. Want to change it to info
- WordPress reset password button not working
- check if post is set to “password protected”
- Why can’t I create an Application Password?
- ‘random_password’ filters not taking effect
- Bypass a WordPress Password Protected Page via url
- My WordPress password for admin account is changing automatically