Browse: Home / Hooks /

learndash_ques_single_answer_correct

apply_filters( 'learndash_ques_single_answer_correct',  boolean $correct,  array $question_data,  int|string $answer_index,  mixed $correct_answer,  array $user_response )

Filters whether the answer to the single type question is correct or not.


Description #


Parameters #

$correct

(boolean) Whether the answer is correct or not.

$question_data

(array) An array of question data.

$answer_index

(int|string) Index of the answer.

$correct_answer

(mixed) Correct answer for the question.

$user_response

(array) An array of user response data.


Source #

File: includes/quiz/ld-quiz-pro.php


Examples #

Note: Extended code example below not guaranteed, you may need to consult with a developer

 <?php
/**
 * Example usage for learndash_ques_single_answer_correct filter.
 */
add_filter(
	'learndash_ques_single_answer_correct',
	function( $correct, $question_data, $answer_index, $correct_answer, $user_response ) {
		// May add any custom logic using $correct, $question_data, $answer_index, $correct_answer, $user_response.

		// Always return $correct.
		return $correct;
	},
	10,
	5
);