Filter uncanny-toolkit-pro

uo_group_certificate_http_url

Filters the base URL for group certificate uploads, allowing customization of the upload directory.

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

Description

Filters the base URL for group completion certificate files. Developers can modify this to point to a custom upload directory, for example, to store certificates in cloud storage or a different server path. The default is the standard WordPress uploads directory.


Usage

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

Return Value

The filtered value.


Examples

add_filter( 'uo_group_certificate_http_url', 'my_custom_group_certificate_url', 10, 1 );

/**
 * Example of how to change the default upload directory for group certificates.
 *
 * This function overrides the default URL for group certificates and points
 * to a custom directory within the WordPress uploads folder.
 *
 * @param string $default_url The default URL for group certificates.
 * @return string The new, custom URL for group certificates.
 */
function my_custom_group_certificate_url( $default_url ) {
	// Define your custom directory path within uploads.
	$custom_directory = 'my-custom-group-certs/';

	// Construct the new URL.
	$new_url = content_url( 'uploads/' . $custom_directory );

	// Optionally, create the directory if it doesn't exist.
	$upload_dir = wp_upload_dir();
	$custom_path = trailingslashit( $upload_dir['basedir'] ) . $custom_directory;
	if ( ! file_exists( $custom_path ) ) {
		wp_mkdir_p( $custom_path );
	}

	return $new_url;
}

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:317

$uo_generate_group_certs = apply_filters( 'uo_generate_group_certificate', true, $generate_pdf_args, $group_id, $user_id );
		if ( ! $uo_generate_group_certs ) {
			return;
		}

		$file = self::generate_pdf( $generate_pdf_args );
		//Allow custom Link to an upload folder
		$http_link = apply_filters( 'uo_group_certificate_http_url', WP_CONTENT_URL . '/uploads/group-certificates/' );
		/**
		 * 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
		 * @author Saad


Scroll to Top