Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
functions.php | Replace MyListing's Contact Form 7 With Elementor Pro
//// INSTRUCTIONS:
//// Copy and paste the code snippet below into the child theme's functions.php file.
//// You can edit the functions.php file from your WordPress dashboard (Appearance > Theme Editor) or via FTP.
---------------------------CODE SNIPPET IS BELOW THIS LINE---------------------------------------------------------
// REPLACE MYLISTING'S CONTACT FORM 7 WITH ELEMENTOR PRO
// If Contact Email field IS NOT filled in by the listing owner, the form will send to the listing owner.
// If Contact Email field IS filled in, the form will send to the email addresses entered, rather than the listing owner.
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' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.