jaredatch/Custom-Metaboxes-and-Fields-for-WordPress — Issue #48: Multicheck stores a new value on every save
Author: billerickson
Created: 2011-12-05 01:37:49+00:00
State: open

Using the code from example-functions.php:

```

array(
'name' => 'Test Multi Checkbox',
'desc' => 'field description (optional)',
'id' => 'test_multicheckbox',
'type' => 'multicheck',
'options' => array(
'check1' => 'Check One',
'check2' => 'Check Two',
'check3' => 'Check Three',
)
),
```

Then add this to page.php (or single.php if your metabox is on posts):

```

global $post;
$multicheck = get_post_meta( $post->ID, 'test_multicheckbox' );
echo '

';
print_r( $multicheck );
echo '

';
```

Every time you save, it adds the value again to the array. Here's what it looks like after I save it 4 times:

```
Array
(
[0] => check1
[1] => check2
[2] => check1
[3] => check2
[4] => check1
[5] => check2
[6] => check1
[7] => check2
[8] => check1
[9] => check2
)
```

When the value is saved, it should do something like $meta = array_unique( $meta ); to remove duplicates.

This should be considered in @randyhoyt 's improvements to multi-value fields in #44