Timetrap::verify_request( array $data, awsmug\Torro_Forms\DB_Objects\Forms\Form $form, awsmug\Torro_Forms\DB_Objects\Submissions\Submission|null $submission = null )

Verifies a request by ensuring that it is not spammy.

Description

See also

Parameters

$data

(array) (Required) Submission POST data.

$form

(awsmug\Torro_Forms\DB_Objects\Forms\Form) (Required) Form object.

$submission

(awsmug\Torro_Forms\DB_Objects\Submissions\Submission|null) (Optional) Submission object, or null if a new submission.

Default value: null

Return

(bool|WP_Error) True if request is not spammy, false or error object otherwise.

Source

File: src/modules/protectors/timetrap.php

	public function verify_request( $data, $form, $submission = null ) {
		if ( empty( $_POST['timestamp'] ) ) {
			return new WP_Error( 'missing_timestamp', __( 'Internal error: Could not verify you are human. Please contact an administrator if you are.', 'torro-forms' ) );
		}

		$now = current_time( 'timestamp' );
		$timestamp = wp_unslash( $_POST['timestamp'] );

		$trigger = $this->get_form_option( $form->id, 'trigger', 3 );

		if ( $now - $timestamp < $trigger ) {
			return new WP_Error( 'timetrap_too_quickly', __( 'You filled this form too quickly to qualify as a human. We understand you possibly are in a hurry, but you really only have to wait a few seconds to send it.', 'torro-forms' ) );
		}

		return true;
	}

Changelog

Changelog
Version Description
1.0.0 Introduced.