Web to Lead html コードを使用して、お問い合わせフォームの詳細を Insightly CRM に送信しようとしています。functions.php で次のコードを使用して、フォームのアクション URL を変更しました。
add_filter('wpcf7_form_action_url', 'wpcf7_custom_form_action_url');
function wpcf7_custom_form_action_url($url) {
global $post;
$id_to_change = 1315;
if($post->ID === $id_to_change)
return 'https://xxxx.insight.ly/WebToLead/Create';
else
return $url;
}
インスペクターではすべて問題ないように見えますが、送信時に次のエラーが発生します。
XMLHttpRequest cannot load https://xxxx.insight.ly/WebToLead/Create. Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://xxxx.com' is therefore not allowed access.
これを functions.php に追加してみました:
add_action( 'init', 'allow_origin' );
function allow_origin() {
header("Access-Control-Allow-Origin: *");
}
これをtheme.phpに追加してみました:
header("Access-Control-Allow-Origin: *");
これを contact form 7 プラグインの scripts.js に追加してみました:
$.ajax({
url: url,
++headers: { 'Access-Control-Allow-Origin': '*' },
++crossDomain: true,
これを .htaccess に追加してみました:
Header always set Access-Control-Allow-Origin "*"
何も機能しません:(私のサーバーにはVarnish 4とConfigServer Security&Firewallがありますが、両方を無効にしても同じエラーが発生します。助けてください:(