Join

Recipient Management for Elementor Pro Single Listing Contact Forms

Don't want to mess with code snippets? Request for this to be a feature of MyListing Pro.

Instructions

  1. Create a new PHP code snippet.
  2. Copy the contents of code snippet below.
  3. Paste the contents into your code snippet.
  4. Review any notes that I’ve provided.
  5. Save and enable the code snippet.
  6. Test.

Snippet

Check out the Replace MyListing’s Contact Form 7 with Elementor Pro guide for more information.

// RECIPIENT MANAGEMENT FOR ELEMENTOR PRO SINGLE LISTING CONTACT FORMS
// If the email field is NOT filled in by the Listing owner, the form will send to the Listing owner.
// If the email field is filled in, the form will send to the email addresses entered.
function contact_form_email_func( $atts ){
	$postID = get_the_ID();
	$job_email = get_post_meta($postID, '_job_email')[0];
	if(!$job_email){
		$author_id = get_post_field('post_author', $postID);
		$job_email = get_the_author_meta('user_email', $author_id);
	}
	return $job_email;
}
add_shortcode( 'contact-form-email', 'contact_form_email_func' );