Action uncanny-toolkit-pro

uo_group_certificate_pdf_url

Fires after a group certificate PDF URL is generated, providing access to the file link and associated data.

add_action( 'uo_group_certificate_pdf_url', $callback, 10, 4 );

Description

Fires after a group completion certificate PDF URL is generated, providing the full HTTP link, group ID, current timestamp, and user ID. Developers can use this action to modify the PDF URL, integrate with external storage, or trigger notifications after certificate creation.


Usage

add_action( 'uo_group_certificate_pdf_url', 'your_function_name', 10, 4 );

Parameters

$http_link_to_file (mixed)
This parameter holds the complete HTTP URL pointing to the generated PDF file for the group certificate.
$group_id (mixed)
This parameter contains the full HTTP URL to the generated PDF file for the group certificate.
$current_time_stamp (mixed)
This parameter contains the ID of the group for which the certificate is being generated.
$user_id (mixed)
This parameter contains a timestamp representing the time the certificate was generated.

Examples

<?php
/**
 * Example function to hook into uo_group_certificate_pdf_url.
 * This function logs the generated PDF URL and optionally modifies it.
 */
add_action( 'uo_group_certificate_pdf_url', 'my_custom_group_certificate_pdf_url_handler', 10, 4 );

/**
 * Handles the uo_group_certificate_pdf_url action.
 *
 * @param string $http_link_to_file The generated HTTP link to the PDF file.
 * @param int    $group_id          The ID of the group.
 * @param int    $current_time_stamp The timestamp of when the certificate was generated.
 * @param int    $user_id           The ID of the user who completed the group.
 */
function my_custom_group_certificate_pdf_url_handler( $http_link_to_file, $group_id, $current_time_stamp, $user_id ) {
    // Log the generated PDF URL for debugging purposes.
    error_log( sprintf(
        'Group Certificate PDF generated for User ID: %d, Group ID: %d. URL: %s',
        $user_id,
        $group_id,
        $http_link_to_file
    ) );

    // Example: You could potentially modify the URL here if needed,
    // for instance, to add a query parameter for tracking or validation.
    // $modified_link = $http_link_to_file . '?source=my_custom_handler';
    // error_log( 'Modified link: ' . $modified_link );

    // If you were to filter this hook instead of acting on it,
    // you would need to return the modified value.
    // return $modified_link;
}
?>

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/group-completion-certificate.php:329

*
		 * @since  3.6.4
		 * @author Saad
		 * @var $http_link
		 */
		$http_link         = apply_filters( 'uo_group_certificate_url', $http_link, $user, $group_id, $certificate_post, self::$current_time_stamp );
		$http_link_to_file = $http_link . $file_name . '.pdf';
		do_action( 'uo_group_certificate_pdf_url', $http_link_to_file, $group_id, self::$current_time_stamp, $user_id );
		$current_certs = get_user_meta( $user_id, $group_cert_meta, true );
		if ( ! empty( $current_certs ) ) {
			$current_certs[][ self::$current_time_stamp ] = $http_link_to_file;
			update_user_meta( $user_id, $group_cert_meta, $current_certs );
		} else {
			$certs[][ self::$current_time_stamp ] = $http_link_to_file;
			add_user_meta( $user_id, $group_cert_meta, $certs );


Scroll to Top