write a pluggable function
方法:写一个函数使用相同的名字,即重写
重写 wp_new_user_notification,当新用户注册时,发送邮件
copy wp_new_user_notification from plug.php, 改写部分邮件内容:
1 <?php 2 /* 3 Plugin Name: Welcome Plugin 4 Plugin URI: http://www.falkonproductions.com/welcome/ 5 Description: This plugin will welcome new users 6 Author: Drew Falkman 7 Version: 1.0 8 Author URI: http://www.falkonproductions.com/ 9 */ 10 11 // override the wp_new_user_notification pluggable function 12 if ( !function_exists('wp_new_user_notification') ) { 13 function wp_new_user_notification($user_id, $plaintext_pass = '') { 14 $user = new WP_User($user_id); 15 16 $user_login = stripslashes($user->user_login); 17 $user_email = stripslashes($user->user_email); 18 19 // The blogname option is escaped with esc_html on the way into the database in sanitize_option 20 // we want to reverse this for the plain text arena of emails. 21 $blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES); 22 23 $message = sprintf(__('New user registration on your site %s:'), $blogname) . "\r\n\r\n"; 24 $message .= sprintf(__('Username: %s'), $user_login) . "\r\n\r\n"; 25 $message .= sprintf(__('E-mail: %s'), $user_email) . "\r\n"; 26 27 @wp_mail(get_option('admin_email'), sprintf(__('[%s] New User Registration'), $blogname), $message); 28 29 if ( empty($plaintext_pass) ) 30 return; 31 32 $message = __('Welcome to mmmStuff.com') . "\r\n\r\n"; 33 $message .= __('Here is your information for future reference: ') . "\r\n\r\n"; 34 $message .= sprintf(__('Username: %s'), $user_login) . "\r\n"; 35 $message .= sprintf(__('Password: %s'), $plaintext_pass) . "\r\n"; 36 $message .= wp_login_url() . "\r\n"; 37 $message .= __('Feel free to come back and check on stuff often!'); 38 39 wp_mail($user_email, sprintf(__('Welcome to: [%s]'), $blogname), $message); 40 } 41 }
浙公网安备 33010602011771号