2017-09-29 16 views
0

우리 커뮤니티에서는 우리 플랫폼 사용을위한 자습서처럼 등록 후 x 일 후에 몇 가지 추가 전자 메일을 보내려고합니다.등록 후 x 일 안에 전자 메일을 보내는 방법

예를 들어, 등록 후 1 일 동안 우리는 당신에게 뭔가를하는 법을 가르쳐 주며, 3 일째에 다른 것을 설명하는 또 다른 이메일을 보내드립니다 ... 그래서 우리는 사람들과 후속 조치를 취할 수 있으므로 느끼지 않습니다. 지역 사회에 버려야한다.

저는 성공하지 못했던 플러그인을 찾고있었습니다.

그래서 코딩 부분에 들어가서 어떻게 든 할 수 있는지 확인하십시오. CronJob과 Wordpress 밖에있는 커스텀 스크립트는 물론을 할 수 있지만 코딩 지식이없는 사람들이 플랫폼을 관리 할 때 멋진 솔루션은 아닙니다. 나는 Wordpress의 기본 이메일 섹션과 같은 이메일을 추가 할 수있는 무언가를 찾고있었습니다.

나는 내가 시도한 것들을 게시해야한다는 것을 알고 있지만 슬프게도이 일을 할 수있는 해결책이나 해결책을 찾지 못했습니다.

Google은 Wordpress + Buddypress + Learndash를 실행 중입니다.

답변

0

음, 여기에서는 일반적으로 플러그인을 제안하지 않습니다. 이 약간 제안을 위해 Software Recommendations 위치를 위해 가십시오 워드 프레스 꼬리표가있다. 추천은이 워드 프레스 태그입니다.

이제 우리는 일정 시간이 지난 후에 메일을 어떻게 처리 할 수 ​​있는지 코딩 개념의 솔루션으로 왔습니다. 여기에 내가 방금 인수를 사용하여 the_dramatist_handle_scheduled_mail()를 호출하여 기본 이벤트 후 이제 이메일 -

add_action('the_dramatist_send_email_after_three_days', 'the_dramatist_send_email_after_three_days_function', 10, 2); 

function the_dramatist_send_email_after_three_days_function($arg_1, $args_2) { 

    $to = '[email protected]'; 
    $user = get_user_by('email', $to); 
    if (1 === get_user_meta($user->ID, 'after_three_days_email', true)) { 
     return false; 
    } 

    $subject = 'The subject'; 
    $body = 'The email body content'; 
    $headers = array('Content-Type: text/html; charset=UTF-8'); 

    $mail_sent = wp_mail($to, $subject, $body, $headers); 
    // After sending the email to every person I prefer to put a record. 
    if ($mail_sent) { 
     update_user_meta($user->ID, 'after_three_days_email', 1); 

     return true; 
    } 
} 

을 보내 당신이 다음과 같은 기능을 추가하려면이 the_dramatist_send_email_after_three_days 후크에 방법 - 지금

function the_dramatist_handle_scheduled_mail($arg_1 = '', $arg_2 = []) { 
    wp_schedule_single_event(
     // Here time() is the time when this is firing and 259200s = 72h = 3d 
     time() + 259200, 
     // Declaring a hook at this point. You can hook any function to this point which you want to fire after three days of any base event. 
     'the_dramatist_send_email_after_three_days', 
     // You can add number of arguments to the hook also. 
     [ $arg_1, $arg_2 ] 
    ); 
    return true; 

} 

을 제안 할 수 있습니다 . 이 방법을 사용하면 wp_schedule_single_event() 기능으로 WordPress에서 예약 된 이벤트를 처리 할 수 ​​있습니다.

위의 답변을 참조하십시오.

0

만료일이있는 필드를 추가하는 사용자 프로필을 확장하는 것이 좋습니다. 예를 들어 다음 예제에서는 _profile_extend_expires 필드를 사용합니다. 그런 다음 meta_query 필터를 사용하여 만료일을 확인할 수 있습니다.

감사합니다. Ed.

function member_expires_one_day() { 
 

 
    $date_today = today_date(); 
 

 
    $date_to_expire = new DateTime($date_today); 
 
    $date_to_expire->add(new DateInterval('P1D')); 
 
    $expires = $date_to_expire->format('Y-m-d'); 
 

 
    $args = array(
 
     'meta_query' => array(
 
        array(
 
         'key' =>  '_profile_extend_expires', 
 
         'value' => $expires, 
 
         'compare' => '==' 
 
        ), 
 
     ) 
 
    ); 
 

 
    $users = get_users($args); 
 

 
}