Contact Form 7 3.9 Beta

Contact Form 7 3.9 is going to be released shortly. In 3.9, I have done much refactoring for its internal structure. Although most users don’t necessarily need this, if you are a developer of add-on plugins for Contact Form 7 or you have customized Contact Form 7 from your theme’s functions.php file, you may need to modify your code to make it workable with Contact Form 7 3.9.

You can download Contact Form 7 3.9-beta from plugin directory. Testing your code with the beta release before Contact Form 7 3.9 is officially released is highly recommended. If you notice that the add-on plugin you are using stops working after upgrading to Contact Form 7 3.9, please inform the author of the add-on plugin that it needs fixes in order to work with Contact Form 7 3.9.

Major changes made in 3.9 are:

  • The WPCF7_Submission, WPCF7_Mail and WPCF7_MailTaggedText classes have been introduced
  • Some properties and methods have moved from the WPCF7_ContactForm class to the three new classes
  • Visibility of some properties and methods has changed to private. This means the properties and methods are no longer accessible directly from your code

In practice, you will need to modify your code like this:

/* Don't do this, since id property is no longer accessible. */
$id = $contact_form->id; // Wrong.

/* Use id() method instead. */
$id = $contact_form->id();

/* Properties form, mail, mail_2, messages, additional_settings are inaccessible as well. */
$form = $contact_form->form; // Wrong.

/* So, use prop() method to access them. */
$form = $contact_form->prop( 'form' );

/* To set the properties, use set_properties() method, like this: */
$mail = $contact_form->prop( 'mail' );
$mail['subject'] = "Well, hello, Dolly";
$contact_form->set_properties( array( 'mail' => $mail ) );

/* WPCF7_ContactForm object no longer has a posted_data property. */
$posted_data = $contact_form->posted_data; // Wrong.

/* Use WPCF7_Submission object's get_posted_data() method to get it. */
$submission = WPCF7_Submission::get_instance();

if ( $submission ) {
	$posted_data = $submission->get_posted_data();