Removing Passwords from WP
-
I use a custom plugin to authenticate and login users, along the lines of:
remove_all_filters('authenticate'); add_filter('authenticate', 'my_auth_function', 10, 3); function my_auth_function($user, $username, $password) { // Do my login stuff, returning either a WP_Error or WP_User object. }
I use wp_insert_user() to either create a new WP user or sync data from our external source to a current WP user, then I log them in.
$UserObj = get_user_by('login', $Username); $InsertUserData = array( 'user_pass' => md5(microtime()), 'user_login' => $Username, 'user_nicename' => $Username, 'user_email' => $Email, 'nickname' => $Username, 'first_name' => $FirstName, 'last_name' => $LastName ); // If wp_insert_user() receives 'ID' in the array, it will update the user data // of an existing account instead of creating a new account. if (false !== $UserObj && is_numeric($UserObj->ID)) { $InsertUserData['ID'] = $UserObj->ID; } $NewUser = wp_insert_user($InsertUserData);
As you can see above, one of the array elements for wp_insert_user() is “user_pass”. I do not want to store passwords in WordPress; we have an external auth system to do this. As you can see above, right now, I do
'user_pass' => md5(microtime())
.Instead of storing a random md5 hash, can I set user_pass to null, false, or an empty string? Would that be better than storing random data in it?
Thanks!
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Removing Passwords from WP’ is closed to new replies.