Updating wp.user password logs out user
-
Hello good people,
I’ve been working with WP for a few months now and have been working with PHP & MySQL for quite a few years. I received a job from a client that was done by another coder and he wasn’t really satisfied with the work (my client). As most people know unless a coder sticks to some normal standards it gets quite difficult to read another man’s code…
Anyway, after making the adjustments my client wanted I was left with one problem that I haven’t been able to solve.
Situation: There’s a login panel on the front of the website that uses the WP login. If you enter the wrong password it will send you to wp-login.php with an error message.
If you login succesfully you arrive on the ‘front-end’ of the website with an admin panel that was created.
Problem: When I go to edit the users password and hit submit, it will change the password and then log me out.
The Code: Here’s the code that the first guy who had this assignment wrote to update the password in the DB:
global $wpdb; $password = $_POST['wachtwoord']; $md5password = wp_hash_password($password); $profile_id = $_POST['prof_id']; $wpdb->query("UPDATE <code>wp_users</code> SET <code>user_login</code> = '".$_POST['log_name']."', <code>user_pass</code> = '{$md5password}' WHERE <code>ID</code> = '" . $profile_id . "'");
I’ve also tried using wp_update_user but that has the same result.
I’ve tried tracking down how it’s done in the WP-admin side of it, but I got a bit lost in the code of WP itself. I figured I would see if anybody here’s got a clue as to why it’s happening and most importantly: if and how I can fix this?
Thanks very much!
Regards,
Fons
- The topic ‘Updating wp.user password logs out user’ is closed to new replies.