I have several fields mostly text inputs to save additional info to the posts, all the text boxes save but i cant't get the checkbox to save the value!
Wondered whether any of you geniuses out there could help me. Thanks in advance.
The checkbox is below, which I echo the ck_sale in the checkbox input
$ck_sale = get_post_meta($post->ID, 'ck_sale_item', true); ?>
<?php //Save the information in the metabox
add_action( 'save_post', 'mb_product_details_save');
function mb_product_details_save( $post_id ) {
// Bail if we're doing an auto save
if( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
return;
}
// if our nonce isn't there, or we can't verify it, bail
if( !isset( $_POST['product_details_nonce'] ) || !wp_verify_nonce( $_POST['product_details_nonce'], 'mb_product_details_nonce' ) ) {
return;
}
// if our current user can't edit this post, bail
if( !current_user_can( 'edit_post' ) ) {
return;
}
//Set the data in the fields before saving
if( isset( $_POST['tb_RRP_price'] ) ) {
update_post_meta( $post_id, 'tb_RRP_price', wp_kses($_POST['tb_RRP_price']));
}
if( isset( $_POST['tb_trade_price'] ) ) {
update_post_meta( $post_id, 'tb_trade_price', wp_kses($_POST['tb_trade_price']));
}
if( isset( $_POST['tb_colours'] ) ) {
update_post_meta( $post_id, 'tb_colours', wp_kses($_POST['tb_colours']));
}
if( isset( $_POST['tb_quantity'] ) ) {
update_post_meta( $post_id, 'tb_quantity', wp_kses($_POST['tb_quantity']));
}
if($_POST["ck_sale_item"] == "on") {
$featured = "on";
}
else {
$featured = "off";
}
update_post_meta($post->ID, 'ck_sale_item', $featured);
} ?>