Skip to content

Instantly share code, notes, and snippets.

@finalwebsites
Created December 9, 2024 07:11
Show Gist options
  • Save finalwebsites/a5f36bd0fc6af000b7c731d5e892c85d to your computer and use it in GitHub Desktop.
Save finalwebsites/a5f36bd0fc6af000b7c731d5e892c85d to your computer and use it in GitHub Desktop.

Revisions

  1. finalwebsites created this gist Dec 9, 2024.
    19 changes: 19 additions & 0 deletions functions.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,19 @@
    <?php

    // Place this code into the functions.php file or your WordPress child theme

    add_action('wpcf7_mail_sent', 'fw_wpcf7_subscribe_to_eo4wp' );
    function fw_wpcf7_subscribe_to_eo4wp( $contact_form ){
    // get form id
    $form_id = $contact_form->id();
    // get submission data
    $submission = WPCF7_Submission::get_instance();
    $posted_data = $submission->get_posted_data();
    if (!empty($posted_data['newsletter'])) {
    $tag = 'newsletter';
    $data = array('tags' => $tag, 'FirstName' => $posted_data['your-name']);
    $list = get_option('fweo_emailoctopus_list_id');
    $eo = new FWEO_EmailOctopus_integration();
    $eo->add_subscriber($posted_data['your-email'], $list, $data);
    }
    }