Submission_Count::can_access( 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

$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|WP_Error) True if the form or submission can be accessed, false or error object otherwise.

Source

File: src/modules/access-controls/submission-count.php

	public function can_access( $form, $submission = null ) {
		$limit = (int) $this->get_form_option( $form->id, 'total_submissions_limit', 100 );

		$submissions = $form->get_submissions( array(
			'number' => $limit,
			'fields' => 'ids',
			'status' => 'completed',
		) );
		if ( count( $submissions ) >= $limit ) {
			$message = $this->get_form_option( $form->id, 'total_submissions_reached_message' );
			if ( empty( $message ) ) {
				$message = $this->get_default_total_submissions_reached_message();
			}

			return new WP_Error( 'total_submissions_reached', $message );
		}

		return true;
	}

Changelog

Changelog
Version Description
1.0.0 Introduced.