LLMS_Question_Manager::get_question( int $id )

Retrieve a question associated with this quiz by question ID


Parameters Parameters

$id

(int) (Required) WP Post ID of the question


Top ↑

Return Return

(boolean)


Top ↑

Source Source

File: includes/class.llms.question.manager.php

	public function get_question( $id ) {

		$question = llms_get_post( $id );

		// Not valid question, return false.
		if ( empty( $question ) || ! is_a( $question, 'LLMS_Question' ) ) {
			return false;
		}

		$parent_id = $question->get( 'parent_id' );

		// When parent id is set, only retrieve questions attached to this parent.
		if ( $parent_id && $parent_id !== $this->get_parent()->get( 'id' ) ) {

			if ( 'llms_question' === $this->get_parent_type() && $this->get_quiz()->get( 'id' ) === $question->get_quiz()->get( 'id' ) ) {
				return $question;
			}

			return false;
		}

		// Success.
		return $question;

	}


Top ↑

Changelog Changelog

Changelog
Version Description
3.16.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.