0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Contact Form 7 add confirmを使えるようにする件

Posted at

はじめに

WordPressのお問い合わせフォームなどで、確認のワンクッションを設けるのに便利な「Contact Form7 add confirm」ですが、
元のプラグイン『Contact Form7』のアップデートにより使えなくなっている案件が多発しまして。。。

とりあえずContact Form7の古いバージョンを当てて元に戻ったのですが、フォームが使えないと機会損失として痛いし、古いバージョンを使い続けるのもおかしな話です。

そんな中、ググってみたら解決方法が出てきたので、一応使いやすいように書き記しておこうと思います。

今回は、「Contact Form7 add confirm」を修正して使えるようにする方法を書きます。

解決方法

ファイル編集

plugins/contact-form-7-add-confirm/includes/js/scripts.jsを編集します。
※git風に書いています。-が元の文、+が加筆文です。

 document.addEventListener( 'wpcf7submit', function( event ) {
        switch ( event.detail.status ) {
                case 'wpcf7c_confirmed':
-               wpcf7c_step1(event.detail.id);
+               wpcf7c_step1(event.detail.unitTag);
                break;
                case 'mail_sent':
-               wpcf7c_step2(event.detail.id);
+               wpcf7c_step2(event.detail.unitTag);
                break;

また、メッセージ不具合修正は下記の+を追加です。

setTimeout(function() { wpcf7c_scroll(parent.find("input[name=_wpcf7_unit_tag]").val()) }, 100);
        }
  
+       // 確認ボタン挙動
+       parent.find(".wpcf7c-btn-confirm").on("click", function() {
+         responseOutput.css("display", "");
+       });
 }

これで動作確認してOKでした。

参考サイトURL

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?