llms_show_take_quiz_button( obj $lesson )

Determines whether or not a “Take Quiz” button should be displayed for a given lesson.


Parameters Parameters

$lesson

(obj) (Required) LLMS_Lesson.


Top ↑

Return Return

(boolean)


Top ↑

Source Source

File: includes/functions/llms-functions-progression.php

function llms_show_take_quiz_button( $lesson ) {

	// If a lesson has a quiz, show the button, otherwise don't.
	$show = $lesson->has_quiz();

	// if the lesson has a quiz make sure we can show the button to the current user.
	if ( $show ) {

		$quiz_id = $lesson->get( 'quiz' );

		// if the quiz isn't published and the current user can't edit the quiz don't show the button.
		if ( 'publish' !== get_post_status( $quiz_id ) && ! current_user_can( 'edit_post', $quiz_id ) ) {
			$show = false;
		}
	}

	// allow 3rd parties to modify default behavior.
	return apply_filters( 'llms_show_take_quiz_button', $show, $lesson );

}


Top ↑

Changelog Changelog

Changelog
Version Description
3.29.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

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