uo_course_certificate_email_message_certificate_attached_text
Commented out so we have full control of message */ Filters the text indicating a certificate is attached to an email, allowing customization of this notification message.
add_filter( 'uo_course_certificate_email_message_certificate_attached_text', $callback, 10, 1 );
Description
This filter hook allows developers to customize the text indicating that a course certificate is attached to an email. It fires after the email message is constructed but before it's sent, giving full control over the notification message for certificate attachments. Modify this text to provide clearer or more branded information to recipients.
Usage
add_filter( 'uo_course_certificate_email_message_certificate_attached_text', 'your_function_name', 10, 1 );
Return Value
The filtered value.
Examples
/**
* Modify the text indicating the certificate is attached to the email.
*
* This filter allows you to customize the default message that informs the user
* their course completion certificate is included as an attachment.
*
* @param string $default_message The default text to display.
* @return string The modified text to display.
*/
add_filter( 'uo_course_certificate_email_message_certificate_attached_text', function( $default_message ) {
// Example: Add the course title before the default message if available.
// This assumes there's a way to access the current course object or its title
// within the context where this filter is applied. For this example, let's assume
// we can retrieve it via a global variable or a function that provides it.
// In a real scenario, you'd need to ensure '$current_course_title' is properly populated.
$current_course_title = ''; // Placeholder: Replace with actual logic to get course title
// You might get the course title from a global variable if set by the plugin
// or by fetching it based on the user and course context.
// For demonstration, let's imagine a function `get_current_course_completion_title()`
// that returns the title of the course for which the certificate is being generated.
if ( function_exists( 'get_current_course_completion_title' ) ) {
$current_course_title = get_current_course_completion_title();
}
if ( ! empty( $current_course_title ) ) {
// Ensure the course title is properly escaped for display.
$escaped_course_title = esc_html( $current_course_title );
$modified_message = sprintf(
__( 'Your certificate for "%s" is attached with this email.', 'your-text-domain' ),
$escaped_course_title
);
return $modified_message;
}
// If no course title is available or the default message is preferred, return it.
return $default_message;
}, 10, 1 );
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:413
$email_message .= "nn";
if ( is_array( $file ) && isset( $file['error'] ) ) {
$email_message .= $file['error'];
} elseif ( apply_filters( 'uo_course_completion_add_certificate_attached', true ) ) {
/** Commented out so we have full control of message */
$email_message_certificate_attached_text = apply_filters( 'uo_course_certificate_email_message_certificate_attached_text', esc_attr__( 'Your certificate is attached with this email.', 'uncanny-pro-toolkit' ));
$email_message .= $email_message_certificate_attached_text;
}
$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 );