0
TwilioとWordpressおよびContactフォーム7プラグインを統合する作業を進めています。受信者Twilioと連絡先フォーム7 - Wordpressに基づいて別の番号にSMSを送信
連絡先フォーム7のフックを作成し、フォーム提出時にTwilioとSMSを送信しました。できます。
私の次のステップは、受信者に基づいて異なる番号に送信することです(連絡先フォーム7に3つの異なる場所があり、受信者は選択した場所に基づいて変更されます)。
私はそれを動作させることはできません。
以下は私のコードですが、どのような考えですか?
このフック作品や1つの番号のみ
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" ) ); }