<?php
defined('ABSPATH') or die('No script kiddies please!!');
if (!empty($form_details['general']['mailchimp_id']) || !empty($std_settings['mailchimp']['mailchimp_lists'])) {
    $post_parameters = array('members' => array(array('email_address' => $form_data['std_email'], 'status' => 'subscribed', 'merge_fields' => array('FNAME' => $fname, 'LNAME' => $lname))), 'update_existing' => true);
    /**
     * Filters parameters being sent to Maichimp
     *
     * @param array $post_parameters
     * @param array $form_data
     * @param array $form_details
     */
    $post_parameters = apply_filters('std_mc_post_parameters', $post_parameters, $form_data, $form_details);
    $settings_mailchimp_lists_obj = json_decode(rtrim($std_settings['mailchimp']['mailchimp_lists']));
    $settings_mailchimp_lists = [];
    if (!empty($std_settings['mailchimp']['enable'])) {
        if (!empty($settings_mailchimp_lists_obj->lists)) {
            foreach ($settings_mailchimp_lists_obj->lists as $mailchimp_list) {
                $settings_mailchimp_lists[] = $mailchimp_list->id;
            }
        }
    }
    $mailchimp_lists = (!empty($form_details['general']['mailchimp_id'])) ? $form_details['general']['mailchimp_id'] : $settings_mailchimp_lists;
    if (!empty($mailchimp_lists)) {
        foreach ($mailchimp_lists as $mailchimp_id) {
            $this->subscribe_to_mailchimp($mailchimp_id, $post_parameters);
        }
    }
}
