HEX
Server: nginx/1.18.0
System: Linux srv01 5.15.0-171-generic #181-Ubuntu SMP Fri Feb 6 22:44:50 UTC 2026 x86_64
User: RaviMohan (1026)
PHP: 7.4.33
Disabled: exec,passthru,shell_exec,system
Upload Files
File: /home/RaviMohan/sdrshilajit.com/web/wp-content/themes/atraxis/functions.php
<?php

define( 'ACF_LITE', true );

include ('advanced-custom-fields/acf.php');

add_filter( 'wp_mail', 'my_custom_to_admin_emails' );

/**
 * Filter WP_Mail Function to Add Multiple Admin Emails
 *
 *
 *
 * @param array $args A compacted array of wp_mail() arguments, including the "to" email,
 *                    subject, message, headers, and attachments values.
 *
 * @return array
 */
function my_custom_to_admin_emails( $args ) {
    // If to isn't set (who knows why it wouldn't) return args
    if( ! isset($args['to']) || empty($args['to']) ) return $args;

    // If TO is an array of emails, means it's probably not an admin email
    if( is_array( $args['to'] ) ) return $args;

    $admin_email = get_option( 'admin_email' );

    // Check if admin email found in string, as TO could be formatted like 'Administrator <[email protected]>',
    // and if we specifically check if it's just the email, we may miss some admin emails.
    if( strpos( $args['to'], $admin_email ) !== FALSE ){
        // Set the TO array key equal to the existing admin email, plus any additional emails
        //
        // All email addresses supplied to wp_mail() as the $to parameter must comply with RFC 2822. Some valid examples:
        // [email protected]
        // User <[email protected]>
        $args['to'] = array( $args['to'], '[email protected]', 'Ravi Mohan <[email protected]>' );
    }

    return $args;
}

?>