learndash_quiz_completed_result_settings

apply_filters( 'learndash_quiz_completed_result_settings',  array $quiz_result_settings,  mixed $quiz_data )

Filters settings of the completed quiz results.


Description #


Parameters #

$quiz_result_settings

(array) An array of quiz result settings data.

$quiz_data

(mixed) An array of quiz data.


Source #

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


Examples #

 <?php
/**
 * Example usage for learndash_quiz_completed_result_settings filter.
 */
add_filter(
	'learndash_quiz_completed_result_settings',
	function( $quiz_result_settings = array(), $quizdata = array() ) {

		// Example 1: If student has less then 60% don't show the 'View Questions' button.
		if ( ( isset( $quizdata['percentage'] ) ) && ( $quizdata['percentage'] < 60 ) ) {
			$quiz_result_settings['showViewQuestionButton'] = 0;
		}

		// Example 2: If student gets 100% don't show the quiz restart button.
		if ( ( isset( $quizdata['percentage'] ) ) && ( $quizdata['percentage'] == 100 ) ) {
			$quiz_result_settings['showRestartQuizButton'] = 0;
		}

		// Always return $quiz_result_settings
		return $quiz_result_settings;

	},
	30,
	2
);