Filter uncanny-toolkit-pro

uo_group_completion_add_certificate_attached

Filters whether a certificate should be attached when a group's lesson is completed.

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

Description

This filter hook allows developers to modify the 'certificate attached' message included in group completion emails. By default, it returns true, enabling the standard message. Developers can return false to prevent the message or return a custom string to replace it entirely, offering flexible control over email content.


Usage

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

Return Value

The filtered value.


Examples

/**
 * Modify the text indicating a certificate is attached to an email.
 *
 * This filter allows developers to customize the message displayed to users
 * when a completion certificate is attached to their email, for example,
 * to include specific instructions or a different wording.
 *
 * @param bool $is_attached Whether the certificate is considered attached. Defaults to true.
 * @return string The modified text to be displayed.
 */
add_filter( 'uo_group_completion_add_certificate_attached', 'my_custom_certificate_attached_text', 10, 1 );

function my_custom_certificate_attached_text( $is_attached ) {
	// If the certificate is confirmed to be attached, change the message.
	// Otherwise, let the default behavior (or other filters) handle it.
	if ( $is_attached ) {
		return esc_html__( 'Good news! Your completion certificate has been successfully attached to this email.', 'your-text-domain' );
	}

	// If $is_attached is false, we don't want to output anything specific from this filter.
	// It's important to return the original value or let other filters decide.
	return $is_attached;
}

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

$email_message = str_ireplace( '%Group Name%', $setup_parameters['group-name'], $email_message );
		$email_message = str_ireplace( '%Group Name%', $ugroups, $email_message );

		$email_message .= "nn";

		if ( is_array( $file ) && isset( $file['error'] ) ) {
			$email_message .= $file['error'];
		} elseif ( apply_filters( 'uo_group_completion_add_certificate_attached', true ) ) {
			$email_message .= esc_attr__( 'Your certificate is attached with this email.', 'uncanny-pro-toolkit' );
		}

		$non_user_body = str_ireplace( '%User%', html_entity_decode( $user->display_name ), $non_user_body );
		$non_user_body = str_ireplace( '%User First Name%', html_entity_decode( $user->first_name ), $non_user_body );
		$non_user_body = str_ireplace( '%User Last Name%', html_entity_decode( $user->last_name ), $non_user_body );
		$non_user_body = str_ireplace( '%User Email%', $user->user_email, $non_user_body );

Scroll to Top