Add a ‘Quiz Results’ Tab with the Quiz Notifications Plugin.

A tab can be automatically inserted on every course, lesson, topic or quiz page.

If you want to save time and stress when inserting our Last Quiz shortcode on every course, lesson or quiz page then use this handy little snippet!

What is a Content Tab?

A content tab, or simply just ‘tab’ for short brings up an additional panel of information when you click on something related in your course. This can be anything from notes about the lesson topic to various tools and links that will help improve how students learn throughout all topics covered by this particular class. With LearnDash’s snippet of code called “Learn Dash Content Tabs Filter,” adding these extra bits suddenly becomes easy! You could easily use the materials tab in your course settings, but if you want to do this dynamically and forget about it. Why not make things easier on yourself by using code? With just a few small changes, you can tailor this code to suit your needs.

If you are using our “Quiz Notifications for LearnDash Plugin” then the following modified code might be just what you need. The snippet below will add a ‘Quiz Results’ tab that will include output from our [[elc_last_quiz …]] shortcode, into every course, lesson, topic and/or quiz page.

When will the Quiz Results Tabs display?

  1. The Quiz Results Tabs will be visible after a user completes a Quiz.
  2. Quizzes need to be associated with a Course, Lesson or Topic page.
  3. After a quiz is successful, the user will continue to their next step. When they return to the lesson or quiz, the new Tab will be visible.

How to use the code?

  • Insert the following code in your themes custom functions.php file or use a plugin called “Code snippets”.
  • A basic knowledge of PHP is required to modify the code.
 * Example usage for learndash_content_tabs filter.
 * @SEE:
 * This snippet will add the tab with Last Quiz shortcode output on all: course, lesson, topic pages,
 * provided there are quiz results. 
	function ( $tabs = array(), $context = '', $course_id = 0, $user_id = 0 ) {

		// Add optional logic to show the custom tab only on certain courses.
//		if( 123 !== $course_id ) {
//			return $tabs;
//		}

		// Check if Quiz Notifications for LearnDash plugin is actived.
		if( ! function_exists( 'elc_ldquiz_last_quiz_callback' ) ){
			return $tabs;

		// List of content types to show the Tab and the Last Quiz. 
		// You can comment or uncomment content types for which the tab will be shown. 
		// Below will show the tab on lesson and topic pages only. 
		$elc_context = array(
//			'course',
		//	'quiz',

		// If this is a post type we want to show Last Quiz, test if there is quiz results to render.
		if( in_array( $context, $elc_context ) ) {
			// Test for timespent only.
			$shortcode_atts = array(
				'show' => "timespent",
			$elc_test = elc_ldquiz_last_quiz_callback( $shortcode_atts );

		// Add our Custom Last Quiz Tab.
		if( ! empty( $elc_test ) && ! isset( $tabs[ 'lastquiz' ] ) ) {
			// show attribute values.
			// The quiz results will be printed in the order as in array.
			$show_ar = array(

			// Last Quiz shortcode attributes.
			// Default values for parameters: 
			// 			'collapsible'     => false,
			// 			'show_essay'      => false,
			// 			'comments'        => false,
			// 			'show_correct'    => true,
			// 			'show_points'     => true,
			// 			'answer_feedback' => false,
			// 			'question_cat'    => false,
			// 			'breadcrumbs'     => false,
			// 			'print_button'    => false,
			$shortcode_atts = array(
				'show' => implode( ',', $show_ar ),
				'show_points' => false,

			// Get the HTML Last Quiz results.
			$elc_content = elc_ldquiz_last_quiz_callback( $shortcode_atts );

			// For print button uncomment line below.
			$elc_content = elc_ldquiz_print_callback( '', $elc_content );

			$tabs[ 'lastquiz' ] = array(
				'id'      => 'lastquiz',
				// The value here is to a CSS class you control to show an icon.
				'icon'    => 'ld-downloads-icon',
				'label'   => 'Quiz Results',
				'content' => $elc_content,

		// Always return $tabs.
		return $tabs;