Get the App
SLTechnology News&Howtos  ›  Servers  › 

The method of correcting the link error of WordPress password setting

Shulou Source: shulou.com Published: 2022-06-02 05:35:33 09月25日 Update

Editor to share with you to correct the WordPress password setting link error method, I believe that most people do not know much about it, so share this article for your reference, I hope you will learn a lot after reading this article, let's go to know it!

Press tutorial column to introduce you to correct WordPress password setting link error method, hope to help friends in need!

When a user registers or forgets a password to get a new password, WordPress automatically sends an authentication link address to the user's mailbox. The user sets the password by opening this link, but often finds that the link is not the correct link to set the password when the link is opened directly.

The reason for this problem is not WordPress. There is no hyperlink in the link address of the normal WordPress password, but QQ Mail is smart enough to add a hyperlink to a link address and add symbols that are not the content of the link address, resulting in a link error. It seems that only QQ Mail, which is commonly used, has this problem. This is a clich é problem, online solutions can be found everywhere, but they are all the same, which fully reflects a big copy of the articles all over the world.

Here is my solution, taking WordPress 5.3.2 as an example:

First, the simplest way

Modify the WordPress program file to delete symbols in the code

Fixed forgot password to get new password link

Open the wp-login.php file in the root directory of the WordPress program, and change about 417 lines of:

$message. ='/','\ 1password, $string);} / modify user registration settings password link add_filter ('wp_new_user_notification_email',' zm_user_notification_email_amend', 10,3); function zm_user_notification_email_amend ($wp_new_user_notification_email, $user, $user_email) {global $wpdb, $wp_hasher;$key = wp_generate_password (20, false) Do_action ('retrieve_password_key', $user- > user_login, $key); if (empty ($wp_hasher)) {require_once ABSPATH. WPINC. '/ class-phpass.php';$wp_hasher = new PasswordHash (8, true);} $hashed = time (). ':. $wp_hasher- > HashPassword ($key); $wpdb- > update ($wpdb- > users, array ('user_activation_key' = > $hashed), array (' user_login' = > $user- > user_login)); $switched_locale = switch_to_locale (get_user_locale ($user)); $message = sprintf (_ (Username:% s'), $user- > display_name). "\ r\ n\ r\ n"; $message. = _ ('To set your password, visit the following address:'). "\ r\ n\ r\ n"; $message. ='. Network_site_url ("wp-login.php?action=rp&key=$key&login=". Rawurlencode ($user- > user_login), 'login'). "\ r\ n\ r\ n"; $wp_new_user_notification_email ['message'] = $message;return $wp_new_user_notification_email;}

A way to correct the reset password link can be found on the Internet, but the code is a little procrastinating, and the method in this article is only a key code solution.

As for the correction of user registration settings password links, after rewriting the mail function to solve, it seems that there is room for simplification of the code, we will study it later.

The above is all the contents of the method to correct the WordPress password setting link error, thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Tags: Links passwords methods codes users errors addresses user registrations programs symbols topics content files mailboxes questions new secrets functions articles help procrastination Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Information vpn MySQL Xiaomi Linux