Module::can_access( bool|awsmug\Torro_Forms\Error $result, awsmug\Torro_Forms\DB_Objects\Forms\Form $form, awsmug\Torro_Forms\DB_Objects\Submissions\Submission|null $submission = null )

Determines whether the current user can access a specific form or submission.

Description

See also

Parameters

$result

(bool|awsmug\Torro_Forms\Error) (Required) Whether a user can access the form. Can be an error object to show a specific message to the user.

$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 no submission is set.

Default value: null

Return

(bool|awsmug\Torro_Forms\Error) True if the form or submission can be accessed, false or error object otherwise.

Source

File: src/modules/access-controls/module.php

	protected function can_access( $result, $form, $submission = null ) {
		if ( ! $result || is_wp_error( $result ) ) {
			return $result;
		}

		foreach ( $this->submodules as $slug => $access_control ) {
			if ( ! $access_control->enabled( $form ) ) {
				continue;
			}

			$sub_result = $access_control->can_access( $form, $submission );
			if ( ! $sub_result || is_wp_error( $sub_result ) ) {
				return $sub_result;
			}
		}

		return $result;
	}

Changelog

Changelog
Version Description
1.0.0 Introduced.