Im using this code to subscribe user to MailerLiteusing contact form 7 if i hard code email value it is adding user to MailerLite subscription list on submit but it did not work with posted data values.

it seems like get_posted_data(); not returning values.


$current_path = getcwd();

require_once 'vendor/autoload.php';
use MailerLite\Campaigns;

add_action( 'wpcf7_mail_sent', 'your_wpcf7_mail_sent_function' ); 

function your_wpcf7_mail_sent_function( $contact_form ) {

    $title = $contact_form->title;
    $submission = WPCF7_Submission::get_instance();

    if ( $submission ) {

        $posted_data = $submission->get_posted_data();

         $name = $posted_data['your-name'];
         $email = $posted_data['your-email'];

        $ML_Subscribers = new MailerLite\Subscribers( '453453453' );

        $subscriber = array(
            'email' => $name,
            'name' =>  $email,

        $subscriber = $ML_Subscribers->setId( '4014513' )->setAutoresponders(false)->add( $subscriber );



closed as off-topic by cybmeta, Pieter Goosen, fuxia Jun 2 '16 at 10:15

This question appears to be off-topic. The users who voted to close gave this specific reason:

If this question can be reworded to fit the rules in the help center, please edit the question.

  • someone down vote this in first look can you pls comment what is wrong this question i came here after research many blogs but this problem was not solved. – Shahid Chaudhary Jun 2 '16 at 6:30
  • It's probably being downvoted because WPSE isn't meant to be used for Third-Party Plugins – Jeffrey von Grumbkow Jun 2 '16 at 9:44

Let's try debug $posted_data with sending email

if ( $submission ) {

    $posted_data = $submission->get_posted_data(); 


    echo '<pre>';
    echo '</pre>';

    $content = ob_get_clean();

    wp_mail($your_mail, 'Debug', $content);

or you can save $content to file

  • Thanks Nefro this is output so get_posted_data return data. but why it is not working in my function. <pre>Array ( [_wpcf7] => 207 [_wpcf7_version] => 4.4.2 [_wpcf7_locale] => en_US [_wpcf7_unit_tag] => wpcf7-f207-p5-o1 [your-name] => shahid [your-email] => shahid.cohdy@gmail.com [_wpcf7_is_ajax_call] => 1 ) </pre> – Shahid Chaudhary Jun 2 '16 at 6:47
  • i was try to debug with session but it is not working in wp. – Shahid Chaudhary Jun 2 '16 at 6:49
  • your $posted_data seems good, I think problem will be with "MailerLite", lets try $content = ob_get_clean(); use at the end of function with enable wordpress and PHP debug – Nefro Jun 2 '16 at 6:51
  • This is insane i was using 'email' => $name, instead 'email' => $email, debugging solve my problem i spend 4 hour to debug posted data with cookies and session. :) Thanks a lot. – Shahid Chaudhary Jun 2 '16 at 6:57

Not the answer you're looking for? Browse other questions tagged or ask your own question.