Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support co-existence of [bw_contact_form] with Easy WP SMTP #2

Open
bobbingwide opened this issue Sep 19, 2018 · 0 comments
Open

Support co-existence of [bw_contact_form] with Easy WP SMTP #2

bobbingwide opened this issue Sep 19, 2018 · 0 comments
Assignees
Labels
enhancement New feature or request

Comments

@bobbingwide
Copy link
Owner

Requirement

Use [bw_contact_form] shortcode in conjunction with easy-wp-smtp.

Explanation

The Easy WP SMTP plugin overrides the from email address (and optionally name) with its own value.
This means that the email sent using [bw_contact_form] does not contain the form submitter's email address. Obviously this information is needed in order to construct a reply.

Solution

Include the following code in functions.php

add_filter( 'bw_email_message', 'sgm_bw_email_message', 11, 2 );
/**
 * Appends From email and contact name to the contact form message
 * 
 * Needed since easy-wp-smtp overrides the From email address.      
 * Since we're in the 'bw_email_message' filter we expect bw_replace_fields to be available.
 *  
 * @param string $message the email content
 * @param array $fields array of name value pairs
 * @return string updated message 
 */
function sgm_bw_email_message( $message, $fields ) {
	bw_trace2();
	$extra_bits = bw_replace_fields( "<br />From: %from%<br />Name: %contact%", $fields );
	$message .= $extra_bits;
	return $message;
}
@bobbingwide bobbingwide added the enhancement New feature or request label Sep 19, 2018
@bobbingwide bobbingwide self-assigned this Sep 19, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant