That error happened because the $savedusers
is not an array — in_array()
requires the second parameter be a valid array, and if it’s not, that error (or warning) is thrown.
And a simple fix to that is by type-casting the variable to an array like so:
$savedusers = (array) get_post_meta( $post_id, 'U_S_C_users', true );
Or better, use wp_parse_id_list()
which makes sure $savedusers
is an array of (user) IDs:
$savedusers = wp_parse_id_list( get_post_meta( $post->ID, 'U_S_C_users', true ) );
(You’ll make the above change in User_specific_content_box_inner()
and User_specific_content_box_inner_save()
where get_post_meta()
is called.)
Secondly, the checkboxes should be made an array by appending []
to their name
like so:
echo '<input type="checkbox" name="U_S_C_users[]" value="'.$user->ID.'"';