• I have a website that features a number of different dealer pages, each contains a Contact Form 7 which I would like to automatically send submissions to the email address specifically for that dealer. The email address can be called dynamically and I can return it via a custom shortcode i.e. [dealer-email]. The problem I am trying to solve is to return this within the form. I have added the following filter to allow custom shortcodes to work within Contact Form 7:

    function shortcodes_in_cf7( $form ) {
    $form = do_shortcode( $form );
    return $form;
    }
    add_filter( ‘wpcf7_form_elements’, ‘shortcodes_in_cf7’ );

    As the [dealer-email] shortcode simply results in producing an email address ie. ‘[email protected]’ I’m not sure why this doesn’t work when added to the ‘to’ field in the Mail section of the form?

    Can anyone help?

    Thank you.

    https://www.ads-software.com/plugins/contact-form-7/

Viewing 4 replies - 1 through 4 (of 4 total)
  • I may be missing the point, but if you have separate dealer pages, why not create a specific contact form for each dealer page, and specify the correct “to” address for that dealer on the Mail tab of each form instead of doing it via PHP?

    Thread Starter md2885

    (@md2885)

    Unfortunately we have over 100 dealer pages, therefore it is not feasible nor future proof to setup individual forms for each dealer.

    Still looking for a solution to solve this, I’m stumped!?

    Okay, what about just having one contact form, and on each dealer page, have a link, button, or whatever you like that passes the the value corresponding to the email address for the particular dealer to the contact form. CF7 can accept values for fields as either $_GET or $_POST variables, and if you were to have a select for the dealer “to” field, you can hide the actual email with the “select with pipes” that CF7 offers and just pass the value (dealer’s name) in the variable.

    Thread Starter md2885

    (@md2885)

    It would be nice to allow people to complete the form there and then without having to go to another page to complete it. Its frustrating because I can call the specific email address dynamically, by shortcode if needed. I would have thought that there would be a way of passing this to the form as you can with elements such as the page/post title etc, but it isn’t looking as simple as that…?

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Populate 'To' field of Mail section using shortcode’ is closed to new replies.