User_Identification::set_submission_data( awsmug\Torro_Forms\DB_Objects\Submissions\Submission $submission, awsmug\Torro_Forms\DB_Objects\Forms\Form $form, array $data )

Sets additional data for a submission when it is created.

Description

Parameters

$submission

(awsmug\Torro_Forms\DB_Objects\Submissions\Submission) (Required) New submission object.

$form

(awsmug\Torro_Forms\DB_Objects\Forms\Form) (Required) Form object the submission belongs to.

$data

(array) (Required) Submission POST data.

Source

File: src/modules/access-controls/user-identification.php

	public function set_submission_data( $submission, $form, $data ) {
		$identification_modes = $this->get_form_option( $form->id, 'identification_modes', array() );

		if ( in_array( 'ip_address', $identification_modes, true ) ) {
			if ( ! empty( $_SERVER['REMOTE_ADDR'] ) ) {
				$validated_ip = filter_var( $_SERVER['REMOTE_ADDR'], FILTER_VALIDATE_IP );
				if ( ! empty( $validated_ip ) ) {
					$submission->remote_addr = $validated_ip;
				}
			}
		}

		if ( in_array( 'cookie', $identification_modes, true ) ) {
			if ( ! isset( $_COOKIE['torro_identity'] ) ) {
				setcookie( 'torro_identity', $submission->user_key, current_time( 'timestamp' ) + 3 * YEAR_IN_SECONDS );
			}
		}
	}

Changelog

Changelog
Version Description
1.0.0 Introduced.