So I’m running into some trouble and unsure how I can do this, but I’d like to supply an array of lists to an Advanced Custom Field ‘Select’ field, which I’m unsure how to do properly.
Here is the form
method inside my widget class:
// This is the backend of the widgets
public function form($instance)
{
$api = MailChimp_API::init();
var_dump($api->get_lists());
// Grab the widget ID
$widget_id = $this->id;
// The ACF Lists are empty at first
$acf_lists = get_field('mailchimp_list', $widget_id) ? get_field('mailchimp_list',$widget_id) : '';
}
The get_lists()
method spills out an multi-dimensional array of lists as shown below:
The $acf_lists
variable is my get_field from the database that is not present at the moment because I don’t have any details to pass to it. Here is the ACF field inside my group:
Here is the lists dropdown inside the widget: