Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*
- Plugin Name: New Register Email Customizer
- Description: Changes the copy in the email sent out to new users
- */
- // Redefine user notification function
- if ( !function_exists('wp_new_user_notification') ) {
- function wp_new_user_notification( $user_id, $deprecated = null, $notify = '' ) {
- if ( $deprecated !== null ) {
- _deprecated_argument( __FUNCTION__, '4.3.1' );
- }
- $user = get_userdata( $user_id );
- // Generate password
- $password = wp_generate_password( 12, false );
- wp_set_password( $password, $user_id );
- // The blogname option is escaped with esc_html on the way into the database in sanitize_option
- // we want to reverse this for the plain text arena of emails.
- $blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES);
- if ( 'user' !== $notify ) {
- $switched_locale = switch_to_locale( get_locale() );
- $message = sprintf( __( 'New user registration on your site %s:' ), $blogname ) . "\r\n\r\n";
- $message .= sprintf( __( 'Username: %s' ), $user->user_login ) . "\r\n\r\n";
- $message .= sprintf( __( 'Email: %s' ), $user->user_email ) . "\r\n";
- $message .= sprintf( __( 'Password: %s' ), $password ) . "\r\n";
- @wp_mail( get_option( 'admin_email' ), sprintf( __( '[%s] New User Registration' ), $blogname ), $message );
- if ( $switched_locale ) {
- restore_previous_locale();
- }
- }
- // `$deprecated was pre-4.3 `$plaintext_pass`. An empty `$plaintext_pass` didn't sent a user notification.
- if ( 'admin' === $notify || ( empty( $deprecated ) && empty( $notify ) ) ) {
- return;
- }
- $switched_locale = switch_to_locale( get_user_locale( $user ) );
- $message = sprintf(__('Username: %s'), $user->user_login) . "\r\n\r\n";
- $message .= get_home_url(). '/wp-login.php/?redirect_to=/investor-center/' . "\n";
- $message .= sprintf(__('Username: %s'), $user->user_login) . "\n";
- $message .= sprintf(__('Password: %s'), $password ) . "\n\n";
- $message .= sprintf(__('If you have any problems, please contact me at %s.'), get_option('admin_email')) . "\n\n";
- wp_mail($user->user_email, sprintf(__('[%s] Your username and password info'), $blogname), $message);
- if ( $switched_locale ) {
- restore_previous_locale();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement