• Hi,
    I would like to register the email in a list after sending a message with contact form 7.
    So I put this code in function.php, but it don’t work. I’m not a developer , I think my code is not correct… Help please …
    My code :

    function contactform7_subscribe2($cfdata) {
    
        $submission = WPCF7_Submission::get_instance();
        $formdata = $submission->get_posted_data();
    	$user_name = $formdata['your-name'];
    	$user_email = $formdata['your-email'];
        $list_id = "3";
        //Problem here
        $this->$MailjetApi = new WP_Mailjet_Api(get_option('mailjet_username'), get_option('mailjet_password'));
        $result = $this->$MailjetApi->addContact(array(
    				'Email'		=> ($user_email,
    				'ListID'	=> $list_id
    			));
    }
    if(isset($_POST['opt-in'])) {
        add_action('wpcf7_mail_sent', 'contactform7_subscribe2', 1);
    }

    https://www.ads-software.com/plugins/mailjet-for-wordpress/

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter Nico free

    (@nico-free)

    The solution is …

    function contactform7_subscribe2($cfdata) {
    
        $submission = WPCF7_Submission::get_instance();
        $formdata = $submission->get_posted_data();
        $user_name = $formdata['your-name'];
        $user_email = $formdata['your-email'];
        $list_id = "3";
    
        $MailjetApi = new WP_Mailjet_Api(get_option('mailjet_username'), get_option('mailjet_password'));
        $result = $MailjetApi->addContact(array(
    				'Email'		=> $user_email,
    				'ListID'	=> $list_id
    			));
    }
    if(isset($_POST['opt-in'])) {
        add_action('wpcf7_mail_sent', 'contactform7_subscribe2', 1);
    }

    Thanks for you input, Nico-free

    I’m trying to establish a registration with secure contact form.
    This will probably help. (I’m not much of a developer either ??

    D

    Hello,
    How can i use you code ?
    Im interesse to use contact from 7 with mailjet,
    I put your code in my function.php, but i nothing appends … wath i have to do , and wath i have to modify in your code.
    Tanks

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Subscription with Contact Form 7’ is closed to new replies.