uo_admin_mail_headers
Filters the email headers for admin notifications, allowing customization of outgoing email metadata before sending.
add_filter( 'uo_admin_mail_headers', $callback, 10, 1 );
Description
Allows modification of email headers when sending administrative notifications, such as completion alerts. Developers can alter recipient addresses, content types, or add custom headers to these administrative emails.
Usage
add_filter( 'uo_admin_mail_headers', 'your_function_name', 10, 1 );
Return Value
The filtered value.
Examples
/**
* Add custom headers to admin emails for certificate completion.
*
* This filter allows you to modify the headers sent with emails to the site administrator
* when a user earns a certificate. You might use this to set a custom 'Reply-To' address
* or add additional headers for tracking or integration purposes.
*
* @param array $headers An array of email headers.
* @return array The modified array of email headers.
*/
add_filter( 'uo_admin_mail_headers', 'my_custom_admin_certificate_headers', 10, 1 );
function my_custom_admin_certificate_headers( $headers ) {
// Ensure we're working with an array
if ( ! is_array( $headers ) ) {
$headers = array();
}
// Add a custom header, for example, to specify a different reply-to address
// or to include a unique identifier for tracking.
// Replace '[email protected]' with your actual no-reply email address.
$headers['Reply-To'] = '[email protected]';
// You could also add other headers, for example:
// $headers['X-Certificate-Completion'] = 'true';
// $headers['X-User-ID'] = $current_user->ID; // Note: $current_user might not be available here.
// You'd need to pass it in if required.
return $headers;
}
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/award-certificate.php:703
//Now let's see if we want to send email to admin and group leader
$is_admin = get_option( 'uncanny-ceu-multiple-notify-admin', 'no' );
$is_group_admin = get_option( 'uncanny-ceu-multiple-notify-group-leader', 'no' );
$email_subject = str_ireplace( 'You earned', $current_user->first_name . ' earned', $email_subject );
if ( 'yes' === (string) $is_admin ) {
$admin_mail_headers = apply_filters( 'uo_admin_mail_headers', array() );
wp_mail( get_bloginfo( 'admin_email' ), $email_subject, $email_message, $admin_mail_headers, $certificate );
}
if ( 'yes' === (string) $is_group_admin ) {
$get_leaders = array();
$user_groups = learndash_get_users_group_ids( $current_user->ID, true );
if ( ! empty( $user_groups ) ) {