Set current user email as $headers From
-
Is there a way to set the current user email address as the From header, without using a field?
Situation:
I have several forms especially for logged-in users and I don’t want to bother them to fill out fields with personal info every time. To identify them I want the From field to contain the current users email address.I tried this:
/* —————————
function filter_email_headers( $headers, $email, $form, $fields ) {
// Add a copy to client$current_user = wp_get_current_user();
$email = $current_user->user_email;$headers[] = ‘From:’ . $email;
return $headers;
}
add_filter( ‘af/form/email/headers/key=FORM_KEY’, ‘filter_email_headers’, 10, 4 );
/* —————————Any pointers? Thanks!
- The topic ‘Set current user email as $headers From’ is closed to new replies.