Site icon Hip-Hop Website Design and Development

replace publish meta for checkbox within the admin when inserted within the front-end

This is my drawback, I permit a sure consumer kind to create customized publish kind within the front-end of my web site, with the wp_insert_post() perform… customers can put values inside a kind and there is couple of enter sorts, checkboxes, ranges, numbers, and textual content fields.
However I’ve an issue with checkbox and radio inputs. when customers save values, they do not seem within the publish within the admin panel, I believe the issue is within the update_post_meta() situation…
right here how was the situation:

     if( isset( $_POST[ 'checkbox_1' ] ) ) {
        update_post_meta( $post_id, 'checkbox_1', 'sure' );
     }else{
        update_post_meta( $post_id, 'checkbox_1', '' ); 
     }

so I modified it like that:

$stored_meta= get_post_meta($post_id);

     if(isset( $_POST[ 'checkbox_1' ] ) ) {
        update_post_meta( $post_id, 'checkbox_1', $_POST[ 'checkbox_1' ]) ;
     }else{
        update_post_meta( $post_id, 'checkbox_1', $stored_meta['checkbox_1'][0]); 
     }

Now they seem, however it’s inconceivable to switch them within the admin panel, for instance if consumer checked an enter, even when I unchek it, it stays verify after replace.

I’ve tried different logic, however all of them failed.

this is how look my checkbox enter:

<enter kind="checkbox" title="checkbox_1" worth='sure' <?php if ( isset ( $stored_meta['checkbox_1'][0] ) ) checked( $stored_meta['checkbox_1'][0], 'sure'); ?>>