How does WordPress modify the email content registered with a new user?

Source: Internet
Author: User
Tags sprintf

The simplest way


1. Manually modify

Modify the following section in the pluggable. php directory of wordpresswp-uplodes:

The code is as follows: Copy code

$ Message = sprintf (_ ('username: % S'), $ user_login )."";
$ Message. = sprintf (_ ('password: % S'), $ plaintext_pass )."";
$ Message. = wp_login_url ()."";
Wp_mail ($ user_email, sprintf (_ ('[% s] Your username and password'), $ blogname), $ message );

For example:

The code is as follows: Copy code

$ Message. = sprintf (_ ('Welcome to the *** net'). "rn ";
 
$ Message. = sprintf (_ ('username: % S'), $ user_login). "rn ";
$ Message. = sprintf (_ ('password: % S'), $ plaintext_pass). "rn ";
$ Message. = wp_login_url (). "rn ";
$ Message. = sprintf (_ ('The account must be further reviewed before you can log on, please notify the website administrator '). "rn ";
Wp_mail ($ user_email, sprintf (_ ('[% s] Your username and password'), $ blogname), $ message );

Method 2

Add the redefined wp_new_user_notification function to functions. php of the current topic. The following is an example, which can be modified as needed:

The code is as follows: Copy code

If (! Function_exists ('WP _ new_user_notification ')):
/**
* Login y the blog admin of a new user, normally via email.
 *
* @ Since 2.0
 *
* @ Param int $ user_id User ID
* @ Param string $ plaintext_pass Optional. The user's plaintext password
*/
Function wp_new_user_notification ($ user_id, $ plaintext_pass = ''){
$ User = get_userdata ($ user_id );

$ User_login = stripslashes ($ user-> user_login );
$ User_email = stripslashes ($ user-> user_email );

// Obtain the blog name
$ Blogname = wp_specialchars_decode (get_option ('blogname'), ENT_QUOTES );

// The email content sent to the Postmaster. The content is in HTML format.
$ Message = '

// Send an email to the website administrator
$ Message_headers = "Content-Type: text/html; charset =" UTF-8 "n ";
@ Wp_mail (get_option ('admin _ email '), sprintf (_ (' [% s] New User Registration '), $ blogname), $ message, $ message_headers );

If (empty ($ plaintext_pass ))
Return;
   
// You can modify the notification Email sent to new users in HTML format.
$ Message = '

// Sprintf (_ ('[% s] Your username and password'), $ blogname) is the Mail title
Wp_mail ($ user_email, sprintf (_ ('[% s] Your username and password'), $ blogname), $ message, $ message_headers );
}
Endif;

You can write the content in the $ message in the middle as you like.

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.