AIサマリー
説明
について wpforms_process_validate_email アクションは メールアドレス フォームが送信されたときのフォーム・フィールド。
パラメータ
- フィールドID
- (int)フィールドID。
- フィールド・サブミット
- (配列)そのフィールドに対して送信された、生の/未サニタイズのフィールド値。
- フォームデータ
- (配列) 処理済みのフォーム設定/データ。
ソース
wpforms/includes/class-process.php
詳細情報
について wpforms_process_validate_email アクションは メールアドレス フォームフィールドで使用できます。 この関数はすべてのフォームフィールドに使用できます。 do_action( wpforms_process_validate_{$field_type}, $field_id, $field_submit, $form_data ).
例えば 単一行テキスト フィールドでは do_action( wpforms_process_validate_text, $field_id, $field_submit, $form_data ).
フィールドの値がサニタイズされるのは、処理の後半、つまり wpforms_process_format_{$field_type}.
例
このアクションを使用して、以前にスパムとしてフラグを立てた特定のメールアドレスをスキャンし、ブロックすることができます。
/*
* Check the email address field for blocked emails.
*
* @link https://wpforms.com/developers/wpforms_process_validate_email/
*
* @param int $field_id Field ID.
* @param array $field_submit Unsanitized field value submitted for the field.
* @param array $form_data Form data and settings.
*/
function wpf_dev_block_email_address( $field_id, $field_submit, $form_data ) {
//Create your list of blocked email addresses separated by commas
$blocked_emails = array(
'[email protected]',
'[email protected]'
);
foreach( $blocked_emails as $email ) {
if(strpos($field_submit, $email) !== FALSE ) {
wpforms()->process->errors[ $form_data[ 'id' ] ][ $field_id ] = esc_html__( 'Your email address has been flagged as spam. Please contact the site administrator directly if you have further questions.', 'wpforms' );
return;
}
}
}
add_action( 'wpforms_process_validate_email', 'wpf_dev_block_email_address', 10, 3 );
関連
記事の参照グローバル拒否リストの作成方法