Why do generated passwords start/end with spaces?

If wp_generate_password() was called with the third parameter $extra_special_chars = true a space might be part of the password: function wp_generate_password( $length = 12, $special_chars = true, $extra_special_chars = false ) { $chars=”abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789″; if ( $special_chars ) $chars .= ‘!@#$%^&*()’; if ( $extra_special_chars ) $chars .= ‘-_ []{}<>~`+=,.;:/?|’; $password = ”; for ( $i = … Read more

How to add Wp_error using lostpassword_post hook when validating custom field?

As of WordPress 4.4, the action lostpassword_post passes the $errors object: function wpse_185243_lastpassword_post( $errors ) { if ( ! $captcha_valid /* The result of your captcha */ ) { $errors->add( ‘invalid_captcha’, ‘<strong>ERROR:</strong> Try again sonny.’ ); } } add_action( ‘lostpassword_post’, ‘wpse_185243_lastpassword_post’ ); Pre 4.4 legacy answer Here’s the relevant code you’re referring to (retrieve_password() in … Read more

Customizing lost password email

You want the filters… retrieve_password_message for the actual email content. Your hooked function will get the message as the first argument and the user’s reset key as the second. <?php add_filter(‘retrieve_password_message’, ‘wpse103299_reset_msg’, 10, 2); function wpse103299_reset_msg($message, $reset_key) { // … } retrieve_password_title for the the email subject. <?php add_filter(‘retrieve_password_title’, ‘wpse103299_reset_subject’); function wpse103299_reset_subject($subject) { // … … Read more

Best way to send users password?

You shouldn’t have to send them passwords. That’s a bad idea. Instead, make sure your web server has email setup properly and your user accounts have the correct email addresses. Then all you’ll have to do is send them the link to the Forgot Password link provided by WordPress by default. It looks like this: … Read more

Check the password of a user

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 of hello (instead of hash from user’s profile). It does and then WP thinks this is correct, but outdated md5 hash – … Read more