0
Twilio를 Wordpress 및 연락처 양식 7 플러그인과 통합하려고합니다.받는 사람 Twilio 및 연락처 양식 7 - Wordpress에 따라 다른 번호로 SMS 보내기
양식 제출시 Twilio와 함께 SMS를 보내려면 Contact 양식 7에 후크를 만들었습니다. 그것은 작동합니다.
내 다음 단계는 수신자를 기반으로 다른 번호로 전송하는 것입니다 (연락처 양식 7에 3 개의 다른 위치가 있고 선택한 위치에 따라받는 사람이 변경됨).
나는 제대로 작동하지 않습니다.
아래 코드는 어떤 생각입니까?
이 후크 작품 만
add_action('wpcf7_mail_sent', 'your_wpcf7_mail_sent_function'); function your_wpcf7_mail_sent_function() { $sid = 'xxx'; $token = 'xxx'; $client = new Client($sid, $token); $to = '+1111111111'; $client->messages->create( // the number you'd like to send the message to $to, array( 'from' =>'+1212121211', 'body' => "form submitted" ) ); }
이 두 번째 부분입니다, 나는 그것이 작동 할 수없는 한 번호로 전송합니다. 여기
global $to; function wpcf7_do_something (&$WPCF7_ContactForm) { if ($WPCF7_ContactForm->mail['recipient'] = "[email protected]") { $to = '+1XXXXXXXXX'; } else if($WPCF7_ContactForm->mail['recipient'] = "[email protected]") { $to = '+1x1x1x1x1x'; } else { $to = "+1000000000" } } add_action('wpcf7_before_send_mail', 'wpcf7_do_something'); add_action('wpcf7_mail_sent', 'your_wpcf7_mail_sent_function'); function your_wpcf7_mail_sent_function() { $sid = 'xxxxxxx'; $token = 'xxxxxxx'; $client = new Client($sid, $token); $client->messages->create( // the number you'd like to send the message to $to, array( 'from' =>'+1XXXXXXXXX', 'body' => "form submitted" ) ); }