Title: WordPress 4.0 compatibility issues
Last modified: August 22, 2016

---

# WordPress 4.0 compatibility issues

 *  [RyanHipkiss](https://wordpress.org/support/users/ryanhipkiss/)
 * (@ryanhipkiss)
 * [11 years, 8 months ago](https://wordpress.org/support/topic/wordpress-40-compatibility-issues/)
 * Hi,
 * is anyone else having any compatibility issues with wordpress 4.0?
 * It’s not saving my subscribers to the list in CM.
 * Cheers.
 * [https://wordpress.org/plugins/contact-form-7-campaignmonitor-addon/](https://wordpress.org/plugins/contact-form-7-campaignmonitor-addon/)

Viewing 2 replies - 1 through 2 (of 2 total)

 *  [fmzac](https://wordpress.org/support/users/fmzac/)
 * (@fmzac)
 * [11 years, 7 months ago](https://wordpress.org/support/topic/wordpress-40-compatibility-issues/#post-5351360)
 * This is not WP issue. this is due to contact form 7 changes.
 * In file cf7-campaignmonitor.php on line approx:161 replace whole function `function
   wpcf7_cm_subscribe($obj)` with this code
 *     ```
       function wpcf7_cm_subscribe($obj)
       {
       	$cf7_cm = get_option( 'cf7_cm_'.$obj->id() );
       	$submission = WPCF7_Submission::get_instance();
   
       	if( $cf7_cm )
       	{
       		$subscribe = false;
   
       		$regex = '/\[\s*([a-zA-Z_][0-9a-zA-Z:._-]*)\s*\]/';
       		$callback = array( &$obj, 'cf7_cm_callback' );
   
       		$email = cf7_cm_tag_replace( $regex, $cf7_cm['email'], $submission->get_posted_data() );
       		$name = cf7_cm_tag_replace( $regex, $cf7_cm['name'], $submission->get_posted_data() );
   
       		$lists = cf7_cm_tag_replace( $regex, $cf7_cm['list'], $submission->get_posted_data() );
       		$listarr = explode(',',$lists);
   
       		if( isset($cf7_cm['accept']) && strlen($cf7_cm['accept']) != 0 )
       		{
       			$accept = cf7_cm_tag_replace( $regex, $cf7_cm['accept'], $submission->get_posted_data() );
       			if($accept != $cf7_cm['accept'])
       			{
       				if(strlen($accept) > 0)
       					$subscribe = true;
       			}
       		}
       		else
       		{
       			$subscribe = true;
       		}
   
       		for($i=1;$i<=20;$i++){
   
       			if( isset($cf7_cm['CustomKey'.$i]) && isset($cf7_cm['CustomValue'.$i]) && strlen(trim($cf7_cm['CustomValue'.$i])) != 0 )
       			{
       				$CustomFields[] = array('Key'=>trim($cf7_cm['CustomKey'.$i]), 'Value'=>cf7_cm_tag_replace( $regex, trim($cf7_cm['CustomValue'.$i]), $submission->get_posted_data() ) );
       			}
   
       		}
   
       		if( isset($cf7_cm['resubscribeoption']) && strlen($cf7_cm['resubscribeoption']) != 0 )
       		{
       			$ResubscribeOption = true;
       		}
       			else
       		{
       			$ResubscribeOption = false;
       		}
   
       		if($subscribe && $email != $cf7_cm['email'])
       		{
   
       			require_once(dirname(__FILE__).DIRECTORY_SEPARATOR.'csrest_subscribers.php');
   
       			$wrap = new CF7CM_CS_REST_Subscribers( trim($listarr[0]), $cf7_cm['api'] );
       			foreach($listarr as $listid)
       			{
       				$wrap->set_list_id(trim($listid));
       				$wrap->add(array(
       					'EmailAddress' => $email,
       					'Name' => $name,
       					'CustomFields' => $CustomFields,
       					'Resubscribe' => $ResubscribeOption
       				));
       			}
   
       		}
   
       	}
       }
       ```
   
 * basically these are the changes you need to take care if you are using any custom
   code related to contact form 7
 *     ```
       /* 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();
       }
       ```
   
 *  [lukeyates1981](https://wordpress.org/support/users/lukeyates1981/)
 * (@lukeyates1981)
 * [11 years, 6 months ago](https://wordpress.org/support/topic/wordpress-40-compatibility-issues/#post-5351437)
 * Hi,
 * If you need to get this working in WP 4.0.1 with CF7 v4.0.2, you need to change
   the function mentioned above, but you also need to change:
 * add_action( ‘wpcf7_admin_before_subsubsub’, ‘add_cm_meta’ );
 * to:
 * add_action( ‘wpcf7_admin_notices’, ‘add_cm_meta’ );
 * around line 40 of cf7-campaignmonitor.php 🙂
 * As soon as I found this little gem hidden away on Google, the campaign monitor
   settings all popped up again and were still set to the previous settings.
 * P.S. Thanks fmzac for the function change 🙂

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘WordPress 4.0 compatibility issues’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/contact-form-7-campaignmonitor-addon_abbdd6.
   svg)
 * [Contact Form 7 - Campaign Monitor Addon](https://wordpress.org/plugins/contact-form-7-campaignmonitor-addon/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/contact-form-7-campaignmonitor-addon/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/contact-form-7-campaignmonitor-addon/)
 * [Active Topics](https://wordpress.org/support/plugin/contact-form-7-campaignmonitor-addon/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/contact-form-7-campaignmonitor-addon/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/contact-form-7-campaignmonitor-addon/reviews/)

 * 2 replies
 * 0 participants
 * Last reply from: [lukeyates1981](https://wordpress.org/support/users/lukeyates1981/)
 * Last activity: [11 years, 6 months ago](https://wordpress.org/support/topic/wordpress-40-compatibility-issues/#post-5351437)
 * Status: not resolved