Filter uncanny-toolkit-pro

uo_quiz_certificate_http_url

Filters the file name for the quiz certificate when it's being generated and saved as an HTTP URL.

add_filter( 'uo_quiz_certificate_http_url', $callback, 10, 1 );

Description

Filters the HTTP URL for a generated quiz certificate. Developers can use this hook to modify the default URL, perhaps pointing to a CDN or a custom storage location, before the certificate link is used or displayed.


Usage

add_filter( 'uo_quiz_certificate_http_url', 'your_function_name', 10, 1 );

Parameters

$file_name (mixed)
This parameter contains the file name of the generated certificate.

Return Value

The filtered value.


Examples

<?php
/**
 * Example of how to use the 'uo_quiz_certificate_http_url' filter to modify the certificate URL.
 * This example appends a query parameter with the current timestamp to the URL,
 * potentially for cache-busting purposes or to indicate a fresh download.
 *
 * @param string $http_link_to_file The original HTTP URL to the certificate PDF.
 * @return string The modified HTTP URL to the certificate PDF.
 */
add_filter( 'uo_quiz_certificate_http_url', function( $http_link_to_file ) {
    // Get the current timestamp.
    $current_timestamp = time();

    // Append the timestamp as a query parameter for cache busting.
    // This ensures that if the certificate is regenerated, a new URL is provided.
    $modified_url = add_query_arg( 't', $current_timestamp, $http_link_to_file );

    return $modified_url;
}, 10, 1 ); // Priority 10, accepts 1 argument.
?>

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/classes/generate-p-d-f-email.php:169

$path_on_server = $file;
		$quiz_post      = $post;
		$quiz_results   = $_post['results']['comp'];
		$current_time   = self::$current_time_stamp;
		do_action( 'uo_quiz_certificate', $path_on_server, $quiz_post, $quiz_results, $certificate_id, $current_user, $current_time );

		//$http_link_to_file = WP_CONTENT_URL . '/uploads/user-certificates/' . $file_name . '.pdf';
		$http_link_to_file = apply_filters( 'uo_quiz_certificate_http_url', WP_CONTENT_URL . '/uploads/user-certificates/' . $file_name . '.pdf' );

		do_action( 'uo_quiz_certificate_url', $http_link_to_file, $quiz_post, $quiz_results, $certificate_id, $current_user, $current_time );

		$course_id = $setup_parameters['course-id'];
		$meta_name = '_sfwd-quizzes-pdf-quiz-' . $course_id;

		//Retrieve any existing certificates from USER


Scroll to Top