2017-10-14 2 views
0

사용자가 WordPress 사이트의 계정을 등록 할 때 보내지는 활성화 전자 메일의 내용을 수정할 수 있습니까?WordPress 활성화 전자 메일 편집

전자 메일의 제목과 본문을 변경하여 내 웹 사이트의 정보와 일치하는 내용을 조금 더 읽을 수 있습니다.

나는 뮤 플러그인 안에서 발견 정의 플러그인에 다음 사항을 추가로 시도,하지만 더 전혀 영향을 갖고있는 것 같아요 : 나는 무엇을 말할 수에서

<?php 
/* 
Plugin Name: Disable Username and Password Notification 
Description: Disables the Username and Password email 
*/ 
// Start changing email body 
function myprefix_change_activation_email_body ($old_body, $domain, $path, $title, $user, $user_email, $key, $meta) { 
    $my_message = "Hi! This is my new email! "; 
    $my_message .= "Your site {$title} is almost ready. We probably also want to include the activation key: {$key} "; 
    $my_message .= "Activate your site here : http://{$domain}{$path}wp-activate.php?key=$key"; 
    // ... other stuff 
    return $my_message; 
} 
add_filter('wpmu_signup_blog_notification_email', 'myprefix_change_activation_email_body', 10, 8); 
// End changing email body 

// Start changing email subject 
function myprefix_change_activation_email_subject ($old_subject, $domain, $path, $title, $user, $user_email, $key, $meta) { 
    $my_subject = "Hi! You just registered on my site!"; 
    return $my_subject; 
} 
add_filter('wpmu_signup_blog_notification_subject', 'myprefix_change_activation_email_subject', 10, 8); 
// End changing email subject 

을, 문제는 필터이다 사용중인 사이트는 내 사이트가 아닌 다중 사이트 설정에 가장 많이 사용됩니다. 그것은 단지 표준 WordPress 사이트입니다. 당신이 찾고있는

건배

+0

내가 말하는거다 정품 인증 이메일이 실제로 플러그인에서오고 기본 WordPress 기능이 아니므로 내 질문과 관련이 없습니다! – damienoneill2001

답변

1

기능은 그것이 pluggable functionwp_new_user_notification입니다. 플러그인 기능은 Wordpress 핵심 기능을 무시하도록하는 기능입니다.

당신은 단순히으로 재정의 할 수

  1. 가 MU-플러그인 폴더에있는 파일을 작성, 당신은 당신이 원하는대로 호출 할 수 있지만, 사용자 정의 새로운 사용자-통지와 같은 의미있는 이름을 제공해야합니다. phpl
  2. 기본 함수를 복사하고 함수가 존재하지 않는지 if 문에 래핑합니다. (이 오류를 생성 할 수없는 경우는 가장 좋은 방법입니다)
  3. 변경 메시지 및 주제 (또는 변경을 원하는)

예 :

<?php 
     /* 
     Plugin Name:  Custom User Notification 
     Plugin URI:  http://www.example.com 
     Description:  Pligin description 
     Version:   1.0 
     Author:   Your Name 
     Author URI:  http://www.authorurl.com 
     */ 


     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'); 
       } 

       global $wpdb, $wp_hasher; 
       $user = get_userdata($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"; 

        @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; 
       } 

       // Generate something random for a password reset key. 
       $key = wp_generate_password(20, false); 

       /** This action is documented in wp-login.php */ 
       do_action('retrieve_password_key', $user->user_login, $key); 

       // Now insert the key, hashed, into the DB. 
       if (empty($wp_hasher)) { 
        require_once ABSPATH . WPINC . '/class-phpass.php'; 
        $wp_hasher = new PasswordHash(8, true); 
       } 
       $hashed = time() . ':' . $wp_hasher->HashPassword($key); 
       $wpdb->update($wpdb->users, array('user_activation_key' => $hashed), array('user_login' => $user->user_login)); 

       $switched_locale = switch_to_locale(get_user_locale($user)); 

       $message = sprintf(__('Username: %s'), $user->user_login) . "\r\n\r\n"; 
       $message .= __('To set your password, visit the following address:') . "\r\n\r\n"; 
       $message .= '<' . network_site_url("wp-login.php?action=rp&key=$key&login=" . rawurlencode($user->user_login), 'login') . ">\r\n\r\n"; 

       $message .= wp_login_url() . "\r\n"; 

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

       if ($switched_locale) { 
        restore_previous_locale(); 
       } 
      } 

     } 
+0

답변 해 주셔서 감사합니다. 내가 말할 수있는 것부터, 내가 언급 한 정품 인증 전자 메일은 실제로 플러그인에서오고 있으며 기본 WordPress 기능이 아니기 때문에 제 질문은 실제로 관련이 없습니다! 도움을 주셔서 다시 한번 감사드립니다. – damienoneill2001

관련 문제