Notice: Function _load_textdomain_just_in_time was called incorrectly. Translation loading for the easy-digital-downloads domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /home/runcloud/webapps/qsmstg-sep25/wp-includes/functions.php on line 6121

Deprecated: Creation of dynamic property EDD_User_History::$plugin_file is deprecated in /home/runcloud/webapps/qsmstg-sep25/wp-content/plugins/edd-user-history/edd-user-history.php on line 88

Deprecated: Creation of dynamic property EDD_User_History::$basename is deprecated in /home/runcloud/webapps/qsmstg-sep25/wp-content/plugins/edd-user-history/edd-user-history.php on line 89

Deprecated: Creation of dynamic property EDD_User_History::$directory_path is deprecated in /home/runcloud/webapps/qsmstg-sep25/wp-content/plugins/edd-user-history/edd-user-history.php on line 90

Deprecated: Creation of dynamic property EDD_User_History::$directory_url is deprecated in /home/runcloud/webapps/qsmstg-sep25/wp-content/plugins/edd-user-history/edd-user-history.php on line 91

Notice: Function _load_textdomain_just_in_time was called incorrectly. Translation loading for the edd-recurring domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /home/runcloud/webapps/qsmstg-sep25/wp-includes/functions.php on line 6121

Notice: Function _load_textdomain_just_in_time was called incorrectly. Translation loading for the edd-recurring domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /home/runcloud/webapps/qsmstg-sep25/wp-includes/functions.php on line 6121
Creating Your Own Template Variables - Quiz And Survey Master

🛍️ Save 15% on orders over $99

There will be times when you will want to create your own template variables. The template variables use a pair of filters to manipulate the text. For text before the quiz has been submitted, we use the “mlw_qmn_template_variable_quiz_page” filter. Examples for this filter include the message before quiz, the message before comments, and the message at the end of the quiz. For text after the quiz has been submitted, we use the “mlw_qmn_template_variable_results_page” filter. Examples for this filter include the user emails, the results pages, and the admin emails.

Both filters pass two parameters: $content and $qmn_quiz_array. $content is the text being filtered and $qmn_quiz_array is an array of almost every value for the quiz at that point. So, lets take a look at what will be in the array for the “mlw_qmn_template_variable_quiz_page” filter:

$qmn_quiz_array["quiz_id"]; //The id of the quiz
$qmn_quiz_array["quiz_name"]; //The name of the quiz
$qmn_quiz_array["quiz_system"]; //The scoring system of the quiz

So, to create a template variable using that filter may look something like below. This adds the %QUIZ_NAME% variable which is replaced with the name of the quiz.

add_filter( 'mlw_qmn_template_variable_quiz_page', 'quiz_name_variable', 10, 2 );
function quiz_name_variable( $content, $qmn_quiz_array )
{
    $content = str_replace( "%QUIZ_NAME%" , $qmn_quiz_array["quiz_name"], $content );
    return $content;
}

Now, lets take a look at the array for the “mlw_qmn_template_variable_results_page” filter:

$qmn_quiz_array["quiz_id"]; //The id of the quiz
$qmn_quiz_array["quiz_name"]; //The name of the quiz
$qmn_quiz_array["quiz_system"]; //The scoring system of the quiz
$qmn_quiz_array["total_points"]; //The total points earned by the user
$qmn_quiz_array["total_score"]; //The score percentage earned by the user
$qmn_quiz_array["total_correct"]; //The number of questions the user answered correctly
$qmn_quiz_array["total_questions"]; //The number of questions the user answered
$qmn_quiz_array["user_name"]; //The name of the user
$qmn_quiz_array["user_business"]; //The business of the user
$qmn_quiz_array["user_email"]; //The email of the user
$qmn_quiz_array["user_phone"]; //The phone number of the user
$qmn_quiz_array["user_id"]; //The user id of the user
$qmn_quiz_array["question_answers_array"]; //The answers/comments given by the user
$qmn_quiz_array["timer"]; //The amount of seconds the user took to complete the quiz
$qmn_quiz_array["comments"]; //The comments provided by the user in the comments area
$qmn_quiz_array["certificate_link"]; //The link to the certificate generated for the user

So, to create a template variable using that filter may look something like below. This adds the %CORRECT_SCORE% variable which is replaced with the score that the user earned.

add_filter( 'mlw_qmn_template_variable_results_page', 'correct_score_variable', 10, 2 );
function correct_score_variable( $content, $qmn_quiz_array )
{
    $content = str_replace( "%CORRECT_SCORE%" , $qmn_quiz_array["total_score"], $content );
    return $content;
}

Lastly, you may want to add your variable to the list of variables. You can do so using the “qmn_template_variable_list” hook. So, for example:

add_action( 'qmn_template_variable_list', 'add_variable_display' );
function add_variable_display()
{
    ?>
        %CURRENT_DATE% – 

<?php }