Support Forum
Hi Guys, Not sure what is happening, I have a CF with hidden fields(code bellow) but can´t get the fields to save the standard value "0" in the postmeta database... any help whould be appreciated !!
<?php
add_filter( 'rwmb_meta_boxes', 'your_prefix_hidden' );
function your_prefix_hidden( $meta_boxes ) {
$prefix = '';
$meta_boxes[] = [
'title' => __( 'hidden', 'your-text-domain' ),
'id' => 'hidden',
'post_types' => ['obra'],
'autosave' => true,
'include' => [
'relation' => 'OR',
'user_role' => ['administrator'],
],
'fields' => [
[
'id' => $prefix . 'soma_staff_d',
'type' => 'hidden',
'columns' => 1,
'std' => 0,
],
[
'id' => $prefix . 'soma_sd_ht',
'type' => 'hidden',
'columns' => 1,
'std' => 0,
],
[
'id' => $prefix . 'soma_staff_i',
'type' => 'hidden',
'columns' => 1,
'std' => 0,
],
[
'id' => $prefix . 'soma_si_ht',
'type' => 'hidden',
'columns' => 1,
'std' => 0,
],
[
'id' => $prefix . 'soma_emp_d',
'type' => 'hidden',
'columns' => 1,
'std' => 0,
],
[
'id' => $prefix . 'soma_ed_ht',
'type' => 'hidden',
'columns' => 1,
'std' => 0,
],
[
'id' => $prefix . 'soma_emp_i',
'type' => 'hidden',
'columns' => 1,
'std' => 0,
],
[
'id' => $prefix . 'soma_ei_ht',
'type' => 'hidden',
'columns' => 1,
'std' => 0,
],
[
'id' => $prefix . 'soma_equip',
'type' => 'hidden',
'columns' => 1,
'std' => 0,
],
[
'id' => $prefix . 'soma_equip_ht',
'type' => 'hidden',
'columns' => 1,
'std' => 0,
],
[
'id' => $prefix . 'acum_staff_d',
'type' => 'hidden',
'columns' => 1,
'std' => 0,
],
[
'id' => $prefix . 'acum_staff_i',
'type' => 'hidden',
'columns' => 1,
'std' => 0,
],
[
'id' => $prefix . 'acum_emp_d',
'type' => 'hidden',
'columns' => 1,
'std' => 0,
],
[
'id' => $prefix . 'acum_emp_i',
'type' => 'hidden',
'columns' => 1,
'std' => 0,
],
[
'id' => $prefix . 'acum_equip',
'type' => 'hidden',
'columns' => 1,
'std' => 0,
],
[
'id' => $prefix . 'acum_sd_ht',
'type' => 'hidden',
'columns' => 1,
'std' => 0,
],
[
'id' => $prefix . 'acum_si_ht',
'type' => 'hidden',
'columns' => 1,
'std' => 0,
],
[
'id' => $prefix . 'acum_ed_ht',
'type' => 'hidden',
'columns' => 1,
'std' => 0,
],
[
'id' => $prefix . 'acum_equip_ht',
'type' => 'hidden',
'columns' => 1,
'std' => 0,
],
[
'id' => $prefix . 'acum_ei_ht',
'type' => 'hidden',
'columns' => 1,
'std' => 0,
],
[
'id' => $prefix . 'soma_tools',
'type' => 'hidden',
'columns' => 1,
'std' => 0,
],
[
'id' => $prefix . 'soma_tools_ht',
'type' => 'hidden',
'columns' => 1,
'std' => 0,
],
[
'id' => $prefix . 'acum_tools',
'type' => 'hidden',
'columns' => 1,
'std' => 0,
],
[
'id' => $prefix . 'acum_tools_ht',
'type' => 'hidden',
'columns' => 1,
'std' => 0,
],
],
];
return $meta_boxes;
}
Many thanks
Hi,
I try to run your code on my local site and after publishing the post, the value 0
of the hidden fields are saved to the database as well. Screenshot https://share.getcloudapp.com/P8uGAb8Y
Hi Long,
Thanks for testing, not sure what was wrong, but it works now, many thanks