Home > Software engineering >  How to override the current registration email tempalate with custom email template in worpdress?
How to override the current registration email tempalate with custom email template in worpdress?

Time:11-12

How can we disable the current email template of registration in wordpress and override with the new custom new email template in wordpress. If anyone know please let us know.

CodePudding user response:

You can use wp_new_user_notification_email filter as defined here. This will allow you to override the default email message sent.

You can also see an implementation of it here.

CodePudding user response:

/**

  • Custom register email */ add_filter( 'wp_new_user_notification_email', 'custom_wp_new_user_notification_email', 10, 3 ); function custom_wp_new_user_notification_email( $wp_new_user_notification_email, $user, $blogname ) {

    $user_login = stripslashes( $user->user_login ); $user_email = stripslashes( $user->user_email ); $login_url = wp_login_url(); $message = __( 'Hi there,' ) . "/r/n/r/n"; $message .= sprintf( __( "Welcome to %s! Here's how to log in:" ), get_option('blogname') ) . "/r/n/r/n"; $message .= wp_login_url() . "/r/n"; $message .= sprintf( __('Username: %s'), $user_login ) . "/r/n"; $message .= sprintf( __('Email: %s'), $user_email ) . "/r/n"; $message .= __( 'Password: The one you entered in the registration form. (For security reason, we save encripted password)' ) . "/r/n/r/n"; $message .= sprintf( __('If you have any problems, please contact me at %s.'), get_option('admin_email') ) . "/r/n/r/n"; $message .= __( 'bye!' );

    $wp_new_user_notification_email['subject'] = sprintf( '[%s] Your credentials.', $blogname ); $wp_new_user_notification_email['headers'] = array('Content-Type: text/html; charset=UTF-8'); $wp_new_user_notification_email['message'] = $message;

    return $wp_new_user_notification_email; }

  • Related