I have a basic Admin panel allowing Admin to save options using Checkbox. Checkboxes are used as multiple selection is necessary for the option
So, Admin Option - Checkbox 1 - Checkbox 2 - Checkbox 3 etc
My Checkboxes are generated on the fly, successfully with
<input type="checkbox" name="firm" id="firm-<?php echo esc_attr( $term->slug ); ?>" value="<?php echo esc_attr( $term->slug ); ?>" <?php checked( true, is_object_in_term( $user->ID, 'firm', $term ) ); ?> /><input type="checkbox" name="firm" id="firm-<?php echo esc_attr( $term->slug ); ?>" value="<?php echo esc_attr( $term->slug ); ?>" <?php checked( true, is_object_in_term( $user->ID, 'firm', $term ) ); ?> />
Then when saving my option, I am trying to do it with
wp_set_object_terms( $user_id, array( $term ), 'firm', false);
BUt only the last term is saved and not the array (if more than 1 checked)
Any idea?