Viewing 2 replies - 1 through 2 (of 2 total)
  • missveronica

    (@missveronicatv)

    @norbertk

    Yes, if you don’t update the meta_values when there are no selected options
    the old values will be displayed.

    foreach( $names as $name ) {        
            if ( isset( $_POST[$name] ) && ! empty( $_POST[$name] )) {
                $submitted = array_map( 'sanitize_text_field', $_POST[$name] );
                update_user_meta( $user_id, $name, $submitted );
            } else {
                update_user_meta( $user_id, $name, array() );
            }
        }
    Thread Starter norbertk

    (@norbertk)

    Thank you, that worked!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Data not being saved in multi-checkbox custom field’ is closed to new replies.