I have both checkbox_list and select_advanced (which has multiple => true) returning a string instead of array even though multiple choices are selected. Why?
// ----- field
[
'name' => esc_html__( 'My Checkbox', 'textdomain' ),
'label_description' => esc_html__( 'My Checkbox', 'textdomain' ),
'id' => 'checkbox_list_field_id',
'type' => 'checkbox_list',
'inline' => false,
'select_all_none' => false,
'options' => [
'option_1' => esc_html__( 'Option 1', 'textdomain' ),
'banana' => esc_html__( 'Banana', 'textdomain' ),
'potato' => esc_html__( 'Potato', 'textdomain' ),
],
],
// ----- then in code
$args = [
'post_type' => 'my_custom_post',
'author__in' => $array_of_user_ids,
'posts_per_page' => -1
];
$query = new WP_Query( $args );
if ( $query->have_posts() ) {
while ( $query->have_posts() ) {
$query->the_post();
$checkbox_list = rwmb_meta( 'checkbox_list_field_id' );
var_dump($checkbox_list);
if ( !is_array( $checkbox_list ) ) {
echo '<h3 style="z-index:100000000000; background: red; padding: 60px; display: block;">NOT ARRAY</h3>';
die();
} else {
echo '<h3 style="z-index:100000000000; background: red; padding: 60px; display: block;">YES ARRAY</h3>';
die();
}
}
wp_reset_postdata();
}