我完成Wordpress插件时遇到的问题很少。基本上,它所做的是为Mailchimp订阅的简单表单。
当API密钥直接存储在变量中时,它成功地将电子邮件订阅到列表(案例1)。但是,当我想使用get_options(案例2)从选项加载API密钥时,它只是不起作用。我几乎尝试了所有事情,我对它一点绝望。
案例1 - 效果很好
$api_key = "4085990a9f0816b54729ac1937d1dbb1-us5";
require('includes/Mailchimp.php');
$Mailchimp = new Mailchimp( $api_key );
$Mailchimp_Lists = new Mailchimp_Lists( $Mailchimp );
$subscriber = $Mailchimp_Lists->subscribe( $list_id, array( 'email' => htmlentities($_POST['email']) ), $merge_vars, $email_type, $double_optin, $update_existing, $replace_interests, $send_welcome );
案例2 - 未订阅电子邮件
$api_key = get_option( 'mcvce_apikey' );
require('includes/Mailchimp.php');
$Mailchimp = new Mailchimp( $api_key );
$Mailchimp_Lists = new Mailchimp_Lists( $Mailchimp );
$subscriber = $Mailchimp_Lists->subscribe( $list_id, array( 'email' => htmlentities($_POST['email']) ), $merge_vars, $email_type, $double_optin, $update_existing, $replace_interests, $send_welcome );
感谢您的帮助。 瓦茨拉夫