サポート » プラグイン » Contact Form 7 wpcf7_feedback_responseが機能しない

  • 解決済 takata9456

    (@takata9456)


    初めて投稿します。何か不備や失礼なことがございましたらご指摘ください。

    借りているX-SERVERがContact Form 7を最新にするように求めていたので、v5.3.2から最新のv5.5.6へ更新したところ、今まで機能していたwpcf7_feedback_responseが機能せず、wpcf7_feedback_responseを使っている直前のエラーメッセージまでは出ますが、それ以降のエラーメッセージが出なくなってしまいました。
    当方の環境を記載します。
    WordPress:5.9.3
    PHP:7.4.25
    Contact Form 7:5.5.6

    以下のコードにて、function.phpに記載しています。

    // Auther Takata
    // エラーの出力位置をカスタマイズする
    /* 参考リンク:https://do-jo.jp/plugins/1307/
     *            https://qiita.com/kinshist/items/7a16a1fe4bae27fe11b2
     *            https://nldot.info/i-want-to-change-the-validation-message-display-position-in-copipable-contact-form-7/
     */
    function wpcf7_custom_item_error_position( $items, $result ) {
    	$class = 'wpcf7-custom-item-error';
    	$names = array( 'birth-year', 'birth-month', 'birth-date', 'qualifications', 'other-qualifications' ); // name属性を指定
    
    	if ( isset( $items['invalid_fields'] ) ) {
    		foreach ( $items['invalid_fields'] as $k => $v ) {
    			$orig = $v['into'];
    			$name = substr( $orig, strrpos($orig, ".") + 1 );
    			if ( in_array( $name, $names ) ) {
    				$items['invalid_fields'][$k]['into'] = ".{$class}.{$name}";
    			}
    		}
    	}
    	return $items;
    }
    add_filter( 'wpcf7_feedback_response', 'wpcf7_custom_item_error_position', 10, 2 );

    Contact Form 7の該当のフォームのコードです。

    <div class="contactform h2-txt">
    <table class="table-style01">
    <tr>
    <th class="hissu">お問い合わせ種別</th>
    <td><p>[radio otoiawase-syubetu use_label_element default:1 "お問い合わせ" "相談・見学希望" "ご応募"]</p></td>
    </tr>
    <tr>
    <th class="hissu">お名前</th>
    <td><p>[text* your-name id:name class:text-long akismet:author]</p><p>例:山田 花子</p></td>
    </tr>
    <tr>
    <th>ふりがな</th>
    <td><p>[text your-kana id:kana class:text-long]</p><p>例:やまだ はなこ</p></td>
    </tr>
    <tr>
    <th class="hissu">生年月日</th>
    <td><p>[select* birth-year class:text-short4 include_blank "1950" "1951" "1952" "1953" "1954" "1955" "1956" "1957" "1958" "1959" "1960" "1961" "1962" "1963" "1964" "1965" "1966" "1967" "1968" "1969" "1970" "1971" "1972" "1973" "1974" "1975" "1976" "1977" "1978" "1979" "1980" "1981" "1982" "1983" "1984" "1985" "1986" "1987" "1988" "1989" "1990" "1991" "1992" "1993" "1994" "1995" "1996" "1997" "1998" "1999" "2000" "2001" "2002" "2003" "2004" "2005"]年[select* birth-month include_blank "1" "2" "3" "4" "5" "6" "7" "8" "9" "10" "11" "12"]月[select* birth-date include_blank "1" "2" "3" "4" "5" "6" "7" "8" "9" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "20" "21" "22" "23" "24" "25" "26" "27" "28" "29" "30" "31"]日</p><span class="wpcf7-custom-item-error birth-year birth-month birth-date"></span></td>
    </tr>
    <tr>
    <th class="hissu">性別</th>
    <td>[radio gender use_label_element default:1 "女性" "男性"]</td>
    </tr>
    <tr>
    <th>ご住所</th>
    <td><span class="p-country-name" style="display:none;">Japan</span><p>郵便番号 [text your-post class:text-short8 class:p-postal-code class:input-xlarge]</p>
    <p>[text your-address class:text-long class:p-region class:p-locality class:p-street-address class:p-extended-address class:input-xlarge]</p><p>例:東京都千代田区千代田1-2-3</p></td>
    </tr>
    <tr>
    <th class="hissu">電話番号</th>
    <td><p>[tel* your-telno class:text-long]</p><p>例:03-1234-5678</p></td>
    </tr>
    <tr>
    <th class="hissu">メールアドレス</th>
    <td><p>[email* your-email class:text-long akismet:author_email]</p></td>
    </tr>
    <tr>
    <th class="hissu">保有資格</th>
    <td><p>[checkbox* qualifications use_label_element "介護福祉士" "社会福祉士" "PT" "OT" "ST" "精神保健福祉士" "保健師" "臨床心理士" "公認心理士" "看護師" "管理栄養士" "介護職員初任者研修" "社会福祉主事任用資格" "サービス管理責任者研修修了"]<span style="display: inline-block;">[checkbox qualifications use_label_element "その他"][text other-qualifications id:other-qualifications size:20]</span></p><span class="wpcf7-custom-item-error qualifications other-qualifications"></span></td>
    </tr>
    <tr>
    <th>お問い合わせ内容</th>
    <td><p>[textarea your-message class:text-long]</p></td>
    </tr>
    </table>
    <p class="submit">[submit "送信する"]</p>
    <script>
    document.addEventListener("DOMContentLoaded", function(event) {
       document.getElementById('other-qualifications').disabled = true;
    });
    var targetCheckbox = document.querySelector('input[type="checkbox"][value="その他"]');
    targetCheckbox.addEventListener('click', function(event) {
       var ischecked = targetCheckbox.checked;
       if( ischecked == true ) {
          // チェックが入っていたら有効化
          document.getElementById('other-qualifications').disabled = false;
       }
       else {
          // チェックが入っていなかったら無効化
          document.getElementById('other-qualifications').disabled = true;
       }
    });
    </script>
    </div>

    どのようにしたら、v5.5.6でも機能するようになるのでしょうか?
    皆様のお知恵をお借り出来たら幸いです。

    ヘルプの必要なページ: [リンクを見るにはログイン]

1件の返信を表示中 - 16 - 16件目 (全16件中)
  • トピック投稿者 takata9456

    (@takata9456)

    munyagu様か作者様からのレスがつくかもと数日待ちましたが、レスはないようなので、解決済みとして
    本件はクローズとさせていただきます。

1件の返信を表示中 - 16 - 16件目 (全16件中)
  • トピック「Contact Form 7 wpcf7_feedback_responseが機能しない」には新たに返信することはできません。