Untitled

mail@pastecode.io avatar
unknown
plain_text
a month ago
849 B
2
Indexable
Never
function add_subaccount_info_to_woocommerce_email($email) {
    // Check if this is the new account email
    if ($email->id === 'customer_new_account') {
        if (isset($_POST['permissionBuy'])){
            // Check if the user is a subaccount
            $parent_id = get_current_user_id(); 
            $parent_user = new WP_User($parent_id);
            if ($parent_user) {
                // Create the custom message
                $custom_message = '<p>' . esc_html__('The parent account that invited you is: ', 'b2bking');
                $custom_message .= esc_html($parent_user->user_login) . '</p>';

                // Output the custom message
                echo wp_kses_post($custom_message);
            }
            
        }
    }
}
add_action('woocommerce_email_footer', 'add_subaccount_info_to_woocommerce_email', 10, 1);
Leave a Comment