How to execute a server side script when contact form 7 is submitted? [closed]

You need wpcf7_before_send_mail hook that gets triggered after sending email successfully. Just add this in your functions.php. add_action( ‘wpcf7_before_send_mail’, ‘process_contact_form_data’ ); function process_contact_form_data( $contact_data ){ var_dump($contact_data->posted_data); $name = $contact_data->posted_data[“your-name”]; $email = $contact_data->posted_data[“your-email”]; echo $name ; echo $email; } You can access fields by their name in $contact_data->posted_data array. Yes. You can redirect to another page … Read more

Contact Form 7 – process form using a PHP script, instead of mailing [closed]

Take a look at the wpcf7_before_send_mail hook CF7 provides. add_action(“wpcf7_before_send_mail”, “wpcf7_do_something_else_with_the_data”); function wpcf7_do_something_else_with_the_data(&$wpcf7_data) { // Everything you should need is in this variable var_dump($wpcf7_data); // I can skip sending the mail if I want to… $wpcf7_data->skip_mail = true; }

How to get current post ID in Contact Form 7 wpcf7_before_send_mail hook action

Due to a backwards-incompatible change in version 5.2, you can no longer retrieve the form’s meta data using get_posted_data(). Instead, you can use the id value in the array returned by get_current(): $contact_form = WPCF7_ContactForm::get_current(); $contact_form_id = $contact_form -> id;

Contact Form 7 – Populate Select List With Taxonomy [closed]

The following is a more up to date way to dynamically populate the built-in select with options and could easily be extended to support more. /** * Dynamic Select List for Contact Form 7 * @usage [select name taxonomy:{$taxonomy} …] * * @param Array $tag * * @return Array $tag */ function dynamic_select_list( $tag ) … Read more

How to modify Contact Form 7 Success/Error Response Output [closed]

After taking a deeper look in to this, I realised that the responses that are displayed are produced via the Contact Form 7 AJAX. So, following the Contact Form 7 documentation on DOM Events, I was able to get this working how I wanted with the following JS code: /* Validation Events for changing response … Read more

Why might a plugin’s ‘do_shortcode’ not work in an AJAX request?

WP Ajax runs both public as well as closed calls via admin.php. This means that you don’t have access to the whole wp environment, such as do_shortcode(), which is inside /wp-includes/shortcodes.php. This still can get worked around (and as well for oEmbed). See the following example that you could use in your AJAX callback to … Read more

Contact form 7 select box different value-text than content-text in option [closed]

It looks like this is supported by Contact Form 7 natively, it’s just not very obvious on how to make it happen. Here’s a documentation page explaining the functionality: http://contactform7.com/selectable-recipient-with-pipes/ Basically, all you have to do is put the values like so: “Visible Value|actual-form-value” What comes before the pipe | character will be shown in … Read more

How to use other shortcodes inside Contact form 7- forms? [closed]

There’s two ways to do what you’re wanting. First way is to add this code to functions.php of the Contact Form 7 plugin: add_filter( ‘wpcf7_form_elements’, ‘mycustom_wpcf7_form_elements’ ); function mycustom_wpcf7_form_elements( $form ) { $form = do_shortcode( $form ); return $form; } That allows you to drop shortcodes directly into CF7. Second is to add the Accordion … Read more