118 votes

How to add placeholder for contact form7 for dropdown?

Contrary to what the accepted answer suggests, it actually is possible and built into Contact Form 7. Here's the actual list of options [select] holds. Pretty much you would define the first option to ...
user avatar
  • 19.6k
15 votes

Contact Form 7 - Execute code AFTER mail send

For anybody still landing here looking for a way to run some PHP code after the email has been sent, Contact Form 7 has a wpcf7_mail_sent hook for exactly this. Usage looks a little like: // ...in ...
user avatar
  • 251
14 votes
Accepted

How to modify Contact Form 7 Success/Error Response Output

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 ...
user avatar
  • 1,545
10 votes
Accepted

Why "Contact Form 7" doesn't update PHPmailer library?

PHPMailer is not part of the plugin, it is shipped with WordPress. So it is up to WordPress to keep it up to date. There is a patch already in ticket #37210. In the mean time, you can create a mu-...
user avatar
  • 105k
8 votes
Accepted

How can I send to multiple Contact Form 7 recipients based on form input?

No need to write any code, Contact form 7 has features of Additional Headers in the Mail section. In that you just need to write the email's header inside the Additional headers textbox in Mail(Second ...
user avatar
  • 1,296
8 votes
Accepted

Contact Form 7 Custom Post Action

As per the CF7 Documentation, you can disable AJAX form submission by placing the following code in your wp-config.php define('WPCF7_LOAD_JS', false);
user avatar
  • 468
8 votes
Accepted

To Disable Wordpress Rest API or Not To Disable?

You personally might not need or rely on the WP REST API, but clearly Contact Form 7 does. And so does WordPress core. Especially future versions (think Gutenberg) will heavily rely on the REST API ...
user avatar
  • 3,644
7 votes
Accepted

Contact Form 7 - Execute code AFTER mail send

EDIT: Please note that as of 2017 'on_sent_ok' is deprecated. This means that your code will stop working at some point in the future (likely by the end of 2017). The recommended solution is using ...
user avatar
7 votes
Accepted

Dynamically send pdf attached to post with contact form 7

Try this instead. There was some internal restructuring in CF7 3.9. add_action('wpcf7_before_send_mail','send_pdf'); function send_pdf( $cf7 ) { $id = $cf7->id(); if ($id==741){ ...
user avatar
7 votes

Adding a hyperlink to the checkbox in the contact form 7

It should work like said in my comment but maybe an even better way would be to use the acceptance filed-type that is build especially for that kind of checkboxes. [acceptance term_and_conditions ...
user avatar
7 votes

How to disable autocomplete for inputs in contact form 7?

According to the question and answer from the developer placed here: https://wordpress.org/support/topic/autocomplete-off-3/ You just need to add the autocomplete:off option to the shortcode: [email ...
user avatar
  • 545
6 votes

contactform7 remove tags with "wpcf7_autop false" from functions.php

If you have already upgraded CF7 to version 5.0 or higher, then you can use the new hook: add_filter( 'wpcf7_autop_or_not', '__return_false' );
user avatar
5 votes
Accepted

Contact Form 7: wp_mail doesn't work after update to 4.6

The solution has been found here - Make WordPress Core I've made changes in wp-includes/pluggable.php on line 352 from $phpmailer->setFrom( $from_email, $from_name ); to $phpmailer->setFrom(...
user avatar
  • 151
5 votes
Accepted

How to disable autocomplete for inputs in contact form 7?

Autocomplete tag in form settings does not work anymore (as today Contact Form 7 plugin version 5.1.3. The only solution which worked for me was to add custom attributes thanks to https://...
user avatar
5 votes
Accepted

How to save contact form 7 data in Custom Post Types (CPT)

If you want to save the Mail Content after the Contact Form was sent (or failed), you can use the wpcf7_mail_sent and wpcf7_mail_failed Hookes like this: add_action('wpcf7_mail_sent','...
user avatar
5 votes

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

You can get the post ID from array variable $posted_data the form was send from if ($submission) { $posted_data = $submission->get_posted_data(); print_r($posted_data) } if you ...
user avatar
  • 333
4 votes

Add php variables to custom form submission

I might have a solution for you. But I have to say I'm not sure I understood what u want. So, here is what I designed, step by step: The user will access a page where he needs to insert an e-...
user avatar
4 votes

Vue.js + AJAX Shortcode

My solution was simpler than I thought.... Since I'm just trying to execute shortcodes in the frontend, I can just localize the script and pass the shortcodes as variables: functions.php ...
user avatar
4 votes
Accepted

Creating a contact form without a plugin

This is my very simple implementation of contact form: class WPSE_299521_Form { /** * Class constructor */ public function __construct() { $this->define_hooks(); } ...
user avatar
  • 2,382
4 votes
Accepted

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():...
user avatar
3 votes

Can I make Contact Form 7 change over to a new page?

In order to split a long list of form into multiple steps using Contact Form 7. There is a free plugin availble, Contact Form 7 Multi Steps Module Install this plugin and follow the instructions as ...
user avatar
3 votes

Can I make Contact Form 7 change over to a new page?

Alternatively you could use JavaScript or jQuery. Put each "page" of the form in a its own section / div. Hide all of the divs but the first, and have a button which will hide the current section/...
user avatar
  • 288
3 votes

Contact Form 7: wp_mail doesn't work after update to 4.6

On you on WAMP? Regardless, it sounds like the built-in php mail() function in your php build is unavailable for whatever reason (it doesn't usually work on WAMP or on *nix builds that don't have an ...
user avatar
  • 1,243
3 votes
Accepted

Contact Form 7 pre email processing

Contact form 7 changed classes in 3.9 version. Now this is how it goes. add_action( 'wpcf7_before_send_mail', 'process_form' ); function process_form( $cf7 ) { $submission = WPCF7_Submission::...
user avatar
  • 8,181
3 votes
Accepted

Why not to include reference to /wp-admin/admin.php in Plugin

Could somebody explain why it's advised never to load wp-admin/admin.php in your plugin and how it could cause issues? Because it is loading WordPress out of context-- well, parts of WordPress. And ...
user avatar
  • 63.6k
3 votes

Get value of contact form 7 radio button

Depending when you'd like to take the action you should change the hook - I've chosen wpcf7_before_send_mail - your function function wpcf7_cstm_function($contact_form) { $title = $contact_form-&...
user avatar
  • 1,019
3 votes

Store and Encrypt Contact Form 7 Submissions in Database?

As @kero said, use a CF7 hook. I'd use the wpcf7_before_send_mail hook. Grab data from the CF7 form object's fields, and use those values to store data. I wrote a post to myself on how to get data ...
user avatar
3 votes
Accepted

Contact Form 7 in Multisite

The only thing that multisite networks share are users, Contact Form 7 forms will not be shared between sites. You will need to create a new form in each site
user avatar
3 votes

Custom contact form 7 select with custom values

You can set the values with the filter wpcf7_form_tag and add the shortcode attributes with the filter shortcode_atts_wpcf7 add_filter("wpcf7_form_tag", function($scanned_tag, $replace){ if ("...
user avatar
  • 3,594
3 votes
Accepted

Align reCaptcha to right on Contact Form 7

You can't do that directly inside the CF7 plugin you need to modify the CSS. Add the following to your theme's style.css file: .wpcf7-recaptcha > div { margin: 0 0 15px auto; } PLEASE BE ...
user avatar
  • 681

Only top scored, non community-wiki answers of a minimum length are eligible