Example #1
0
function wpcf7_mailpoet_before_send_mail($contactform)
{
    // make sure the user has Mailpoet (Wysija) and CF7 installed & active
    if (!class_exists('WYSIJA') || !class_exists('WPCF7_Submission')) {
        return;
    }
    //
    if (!empty($contactform->skip_mail)) {
        return;
    }
    //
    $posted_data = null;
    // get the instance that was submitted and the posted data
    $submission = WPCF7_Submission::get_instance();
    $posted_data = $submission ? $submission->get_posted_data() : null;
    // and make sure they have something in their contact form
    if (empty($posted_data)) {
        return;
    }
    // get the tags that are in the form
    $manager = WPCF7_ShortcodeManager::get_instance();
    $scanned_tags = $manager->get_scanned_tags();
    // let's go add the user
    wpcf7_mailpoet_subscribe_to_lists($posted_data, $scanned_tags);
}
function wpcf7_mailpoet_before_send_mail( $contactform ) {
	// make sure the user has Mailpoet (Wysija) installed & active
	if ( ! ( class_exists( 'WYSIJA' ) ) ) {
		return;
	}

	if (! empty( $contactform->skip_mail )) {
		return;
	}

	$posted_data = null;
	if ( class_exists( 'WPCF7_Submission' ) ) {// for Contact-Form-7 3.9 and above, http://contactform7.com/2014/07/02/contact-form-7-39-beta/
		$submission = WPCF7_Submission::get_instance();
		if ( $submission ) {
			$posted_data = $submission->get_posted_data();
		}
	} elseif ( ! empty( $contactform->posted_data ) ) {// for Contact-Form-7 older than 3.9
		$posted_data = $contactform->posted_data;
	}

	// and make sure they have something in their contact form
	if ( empty($posted_data)) {
		return;
	}

	wpcf7_mailpoet_subscribe_to_lists( $posted_data );
}