Support » Fixing WordPress » Contact form

  • Hi.

    I am looking for a contact form that will go to various email addresses depending on the subject field.

    The subject will be in dropdown list and when selected will send form to its related email address.

    Say if “Sales” is selected in subject field then this will go to sales@example.com and if “enquiries” is selected then the contact form will go to enquiries@example.com

    Is there a contact form plugin out there that has this capability?

    • This topic was modified 2 months, 3 weeks ago by Jan Dembowski.

    The page I need help with: [log in to see the link]

Viewing 3 replies - 1 through 3 (of 3 total)
  • Tara King

    (@sparklingrobots)

    Hi @bevilleliam — You might take a look at Gravity or Contact Form to Email. I haven’t used the second one, but they both look like candidates for your use case.

    Thread Starter bevilleliam

    (@bevilleliam)

    Thank you for your reply Tara.

    Gravity forms are deprecated and are untested with my WP theme.

    Contact form to email does not have the feature of sending to a different email address depending on the selected “subject” from dropdown

    Thread Starter bevilleliam

    (@bevilleliam)

    I have my contact form with dropdown subject and I just need to Dynamically change recipient email
    by hook into wpcf7_before_send_mail, get the submitted form data, find the enquiry-type dropdown option and then use an if/else statement to send the notifications to specific email addresses.

    Below is the code I need help in finding where to place on my contact form…..

    `// hook into wpcf7_before_send_mail
    add_action( ‘wpcf7_before_send_mail’, ‘cf7dynamicnotifications’); // Hooking into wpcf7_before_send_mail

    function cf7dynamicnotifications($contact_form) // Create our function to be used in the above hook
    {
    $submission = WPCF7_Submission::get_instance(); // Create instance of WPCF7_Submission class
    $posted_data = $submission->get_posted_data(); // Get all of the submitted form data

    /*
    * Here are our ‘enquiry-type’ options and associated email address for reference
    *
    1 Bookings – rstskryne@gmail.com
    2 Newsletters – therstnewsletter@gmail.com
    4 default – admin@rstskryne.ie
    */

    if( $posted_data[“enquiry-type”] == ‘Bookings’ ) { // If Bookings option is selected
    $recipient_email = ‘rstskryne@gmail.com’;
    }
    elseif($posted_data[“enquiry-type”] == ‘Newsletters’) { // else if Newsletters option is selected
    $recipient_email = ‘therstnewsletter@gmail.com’;
    }
    elseif($posted_data[“enquiry-type”] == ‘Jobs’) { // else if Jobs option is selected
    $recipient_email = ‘jobs@frontendhero.dev’;
    }
    else { // If no dropdown option is selected
    $recipient_email = ‘admin@rstskryne.ie’;
    }
    // set the email address to recipient
    $mailProp = $contact_form->get_properties(‘mail’);
    $mailProp[‘mail’][‘recipient’] = $recipient_email;

    // update the form properties
    $contact_form->set_properties(array(‘mail’ => $mailProp[‘mail’]));
    }

Viewing 3 replies - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.