기본 등록 이메일을 변경하는 방법은 무엇입니까? (플러그인 및 / 또는 비 플러그인) 암호 및 로그인

새 사용자 등록 후 WP는 로그인 / 암호 및 로그인 페이지 링크가 포함 된 이메일을 발송합니다.

이 기본 이메일 템플릿을 변경하는 방법이 있습니까? 제목과 발신자를 변경하고 싶습니다.

편집 : 관심있는 사람을 위해 여기 플러그인 솔루션이 있습니다.



답변

새 사용자 이메일은 wp_new_user_notification()플러그 가능한 기능을 사용하여 전송되며, 이는 덮어 쓸 수 있음을 의미합니다.

// Redefine user notification function
if ( !function_exists('wp_new_user_notification') ) {
    function wp_new_user_notification( $user_id, $plaintext_pass = '' ) {
        $user = new WP_User($user_id);

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

        $message  = sprintf(__('New user registration on your blog %s:'), get_option('blogname')) . "\r\n\r\n";
        $message .= sprintf(__('Username: %s'), $user_login) . "\r\n\r\n";
        $message .= sprintf(__('E-mail: %s'), $user_email) . "\r\n";

        @wp_mail(get_option('admin_email'), sprintf(__('[%s] New User Registration'), get_option('blogname')), $message);

        if ( empty($plaintext_pass) )
            return;

        $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(__('Password: %s'), $plaintext_pass) . "\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 .= __('Adios!');

        wp_mail($user_email, sprintf(__('[%s] Your username and password'), get_option('blogname')), $message);

    }
}


답변

2018 이상 사용자 :

WordPress 4.9.0부터는 사용할 수있는 새로운 필터가 있습니다 (더 이상 플러그인 필요 없음).

관리자에게 보낸 이메일의 사용 예 (테마의 functions.php 에 붙여 넣을 수 있음 ) :

add_filter( 'wp_new_user_notification_email_admin', 'custom_wp_new_user_notification_email', 10, 3 );

function custom_wp_new_user_notification_email( $wp_new_user_notification_email, $user, $blogname ) {
    $wp_new_user_notification_email['subject'] = sprintf( '[%s] New user %s registered.', $blogname, $user->user_login );
    $wp_new_user_notification_email['message'] = sprintf( "%s ( %s ) has registerd to your blog %s.", $user->user_login, $user->user_email, $blogname );
    return $wp_new_user_notification_email;
}


답변

이것은 functions.php에서 작동하지 않습니다.이 코드를 플러그인 안에 넣어야합니다.

이 플러그인을 만들지 않으려면이 링크를 사용 하십시오.

이 함수 양식의 업데이트 코드를 여기 에 가져가는 것을 잊지 마십시오


답변