uo_course_certificate_http_url
Filters the HTTP URL for a course certificate, allowing modification before it's used.
add_filter( 'uo_course_certificate_http_url', $callback, 10, 1 );
Description
Filters the base HTTP URL for course certificates. Developers can modify this URL to point to custom certificate storage locations or implement dynamic URL generation. This hook fires after the default URL is determined, allowing full control over where certificates are served from.
Usage
add_filter( 'uo_course_certificate_http_url', 'your_function_name', 10, 1 );
Parameters
-
$http_link(mixed) - This parameter contains the HTTP URL where course certificates are stored.
Return Value
The filtered value.
Examples
add_filter( 'uo_course_certificate_http_url', 'my_custom_certificate_url', 10, 1 );
/**
* Example function to change the default URL where course certificates are stored.
*
* This function demonstrates how to override the default HTTP URL for course
* certificates by prepending a custom subdomain or CDN URL.
*
* @param string $http_link The current HTTP URL for course certificates.
* @return string The modified HTTP URL for course certificates.
*/
function my_custom_certificate_url( $http_link ) {
// Imagine you have a CDN or a specific subdomain for serving certificates.
// You could dynamically determine this based on site settings or other logic.
$cdn_url = 'https://my-certificate-cdn.com/course-assets/';
// Append the relative path that the original hook generates to the CDN URL.
// We assume the original $http_link will end with something like 'course-certificates/'
// We'll remove any trailing slash from the original link before appending
// to avoid double slashes if the CDN URL already has one.
$relative_path = str_replace( trailingslashit( content_url() ), '', untrailingslashit( $http_link ) );
return trailingslashit( $cdn_url ) . $relative_path;
}
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/course-completion-certificate.php:319
if ( ! empty( $upload_dir['baseurl'] ) ) {
$http_link = trailingslashit( $upload_dir['baseurl'] ) . 'course-certificates/';
} else {
// Fallback or error handling
$http_link = WP_CONTENT_URL . '/uploads/course-certificates/';
}
$http_link = apply_filters( 'uo_course_certificate_http_url', $http_link );
/**
* New filter added so that arguments can be passed. Adding arguments
* to previous filter above might break sites since
* there might be no argument supplied with override function
*
* @since 3.6.4