Support

Account

Home Forums General Issues Submit Contact Form to ACF Email Address

Helping

Submit Contact Form to ACF Email Address

  • I’m building a multi-site that needs to have functioning “Contact Us” forms for each location’s website. These have different email addresses, so I created a custom field for the email address to be entered using ACF. The Form is coded using HTML & PHP. I am trying to figure out how to get the contact forms to email to the separate emails by referencing the specific email address field. Coded like this so far (not working):

    $contact_form_email = get_field(‘contact_form_email’,’options’);

    $email_to = echo ‘”‘.$contact_form_email.'”‘;

    $email_subject = “Submission from Website”;

    That is just the top part. Upon submitting the form, I only get a blank page in return. When I remove the above ACF field reference and replace that section with an actual email address, the form does work. So i know it is something in the code.

    Any help would be greatly appreciated…

  • remove the “echo”. Not required, but you should also add some checking and set a default value:

    
    $email_to = '[email protected]';
    $contact_form_email = get_field(‘contact_form_email’,'options’);
    if ($contact_form_email) {
      $email_to = $contact_form_email;
    }
    $email_subject = “Submission from Website”;
    
Viewing 2 posts - 1 through 2 (of 2 total)

The topic ‘Submit Contact Form to ACF Email Address’ is closed to new replies.