uo_tincanny_quiz_report_user_report_url
Filters the user's report URL for a quiz, allowing modification before it's displayed.
add_filter( 'uo_tincanny_quiz_report_user_report_url', $callback, 10, 1 );
Description
This filter allows developers to modify the user report URL for Tincanny quiz reports before it's passed to the frontend. Use this hook to dynamically change or append parameters to the URL, for example, to direct users to a custom report page or add specific query strings. Fires after quiz data is prepared but before scripts are enqueued.
Usage
add_filter( 'uo_tincanny_quiz_report_user_report_url', 'your_function_name', 10, 1 );
Parameters
-
$user_report_url(mixed) - This parameter contains the URL for the user's quiz report.
Return Value
The filtered value.
Examples
<?php
/**
* Modify the user report URL for Tincanny quiz reports.
*
* This example adds a query parameter to the default user report URL
* to track referral sources for quiz reports.
*
* @param string $user_report_url The original user report URL.
* @return string The modified user report URL.
*/
add_filter(
'uo_tincanny_quiz_report_user_report_url',
function ( $user_report_url ) {
// Ensure $user_report_url is a string before attempting to append.
if ( ! is_string( $user_report_url ) ) {
return $user_report_url; // Return as is if not a string.
}
// Add a custom query parameter for tracking.
$referral_param = 'source';
$referral_value = 'tincanny_quiz_report';
// Check if the URL already has query parameters to decide whether to use '?' or '&'.
$separator = ( strpos( $user_report_url, '?' ) === false ) ? '?' : '&';
$modified_url = esc_url_raw( $user_report_url . $separator . $referral_param . '=' . $referral_value );
return $modified_url;
},
10, // Default priority
1 // Accepted arguments count
);
Placement
This code should be placed in the functions.php file of your active theme, a custom plugin, or using a code snippets plugin.
Source Code
src/reporting/learndash/frontend-reports/quiz-module-reports.php:639
wp_enqueue_script( 'learndash_template_script_js_2', $filepath, array( 'jquery' ), LEARNDASH_VERSION, true );
$data = array();
$data['ajaxurl'] = admin_url( 'admin-ajax.php' );
$data['courses'] = $courses;
$data['groupCourses'] = $group_courses;
$data['userReportUrl'] = apply_filters( 'uo_tincanny_quiz_report_user_report_url', $user_report_url );
$data = array(
'json' => wp_json_encode( $data ),
);
wp_localize_script( 'learndash_template_script_js_2', 'sfwd_data', $data );
}