WordPress in the registration interface to achieve registration after the password directly displayed on the page

Source: Internet
Author: User
Tags setcookie
This article mainly introduces about WordPress in the registration interface to achieve registration password directly displayed on the page, has a certain reference value, now share to everyone, the need for friends can refer to

Objective:

WordPress function is undoubtedly powerful, but some of the features are still a little unsatisfactory, such as the site has a new user registration, must be issued to the user to fill in the mail to receive the new password, and the password is automatically generated by the system, if for some reason the user can not receive mail, resulting in the phenomenon of unable to log in, This kind of user experience is still a bit bad. So you can prompt for the generated password after registering with the new user so that the user can log in directly without waiting for the message to log in.

Do something before you start the change:
WordPress By default is not allowed to register the user, so you need to log in to the background open registration function first.

here is the implementation process:
First, you need to find these two files. wp-login.php, user.php (/wp-includes/user.php)

1. Locate this line of code under Wp-includes/user.php–>function Register_new_user () {}:

1 update_user_option ($user _id, ' Default_password_nag ', true, true); Set up the Password change nag.

Add the sentence below it

1  //write the registered user name and randomly generated password into cookie2 setcookie ("U", $user _login), 3 Setcookie ("User_pass", $user _pass);

(Note: The current WordPress 4.7.3 version is under the/wp-includes/user.php path)

2. Locate this file in the WordPress root directory wp-login.php
and find this code.

1 $errors->add (' Registered ', __ (' registration complete. Please check your email. '), ' message ');

Then replace it with the following code:

1//Read the username and password written into the cookie after registering 2 $errors->add (' Registered ', __ (' registered successfully! User name: '. $_cookie["U"]. ' Password: '. $_cookie["User_pass"]. ' (after logging in to make it easy for you to remember the password), ' message ');

Well, this will enable registration and display the newly registered user name and password on the interface.

The effect is as follows

The above is the whole content of this article, I hope that everyone's learning has helped, more relevant content please pay attention to topic.alibabacloud.com!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.