説明
について wpforms_frontend_form_atts
フィルタは、フォームのロード時に発生し、フォームのフロントエンド属性を表示します。
パラメータ
- ドル
- (array)フォーム属性の配列。
- フォームデータ
- (配列) 処理済みのフォーム設定/データ。
ソース
wpforms/src/Frontend/Frontend.php
詳細情報
フィルタは、特定のフォーム属性の配列に適用されます。
例
以下の例では、この関数はフォーム ID11 に対してブラウザのオートコンプリートを無効にします。 フォームIDを11から、コードを実行したい特定のフォームIDに変更することを忘れないでください。
このチェックを外すと、すべてのフォームに対してコードが実行される。
/** * Remove browser autocomplete. * * @link https://wpforms.com/developers/wpforms_frontend_form_atts/ * * @param array $atts Form attributes. * @param array $form_data Form data and settings. * * return array */ function wpf_dev_disable_form_autocomplete( $atts, $form_data ) { // This check will only form autocomplete for Form #11. // Removing this check would disable autocomplete on ALL forms. if ( absint( $form_data[ 'id' ] ) !== 11 ) { return $atts; } $atts[ 'atts' ][ 'autocomplete' ] = 'nope'; return $atts; } add_filter( 'wpforms_frontend_form_atts', 'wpf_dev_disable_form_autocomplete', 10, 2 );
これらのIDを見つけるのに助けが必要な場合は、こちらのチュートリアルをご覧ください。