uo_group_leader_mail_headers
Filters the email headers for group leader notifications before they are sent.
add_filter( 'uo_group_leader_mail_headers', $callback, 10, 1 );
Description
This filter allows developers to modify the email headers sent to group leaders when awards are generated. It's applied before the email is sent and can be used to add custom headers, modify existing ones, or change the recipients. The hook provides access to the current email headers as an array.
Usage
add_filter( 'uo_group_leader_mail_headers', 'your_function_name', 10, 1 );
Return Value
The filtered value.
Examples
add_filter( 'uo_group_leader_mail_headers', 'my_custom_group_leader_mail_headers', 10, 1 );
/**
* Adds custom headers to the email sent to group leaders.
*
* This function demonstrates how to modify the email headers for group leader notifications.
* It can be used to add custom headers like 'Reply-To' or 'X-Mailer'.
*
* @param array $headers The existing email headers.
* @return array The modified email headers.
*/
function my_custom_group_leader_mail_headers( $headers ) {
// Ensure $headers is an array, as expected by wp_mail.
if ( ! is_array( $headers ) ) {
$headers = array();
}
// Add a custom Reply-To header.
// This is useful if you want replies to go to a specific address rather than the sender.
$headers['Reply-To'] = '[email protected]';
// Add a custom X-Mailer header to identify the system sending the email.
$headers['X-Mailer'] = 'My Awesome WordPress Site Mailer';
// You could also conditionally add headers based on other logic if needed.
// For example, if a specific group leader type should have different headers.
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:732
//self::trace_logs( $get_leaders, 'Get Leaders', 'pdf' );
if ( ! empty( $get_leaders ) ) {
foreach ( $get_leaders as $key => $value ) {
$email_message = str_ireplace( '%Group Name%', get_the_title( $key ), $email_message );
$email_subject = str_ireplace( '%Group Name%', get_the_title( $key ), $email_subject );
//$email = join( ', ', $value );
$group_leader_mail_headers = apply_filters( 'uo_group_leader_mail_headers', array() );
wp_mail( $value, $email_subject, $email_message, $group_leader_mail_headers, $certificate );
}
}
if ( ! is_array( $certificate ) ) {
return;