Im使用此代码向用户订阅MailerLite使用联系表单7如果我硬编码电子邮件值,则在提交时会将用户添加到MailerLite订阅列表,但它不适用于发布的数据值。
看起来像是get_posted_data();
不返回值。
<?php
$current_path = getcwd();
require("$current_path/wp-load.php");
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 );
}
}