Hidden std values not saving in DB
- This topic has 2 replies, 2 voices, and was last updated 3 years, 7 months ago by
toni bird.
Viewing 3 posts - 1 through 3 (of 3 total)
-
AuthorPosts
-
September 28, 2021 at 9:51 PM #31051
toni bird
ParticipantHi 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
September 29, 2021 at 12:49 PM #31062Long Nguyen
ModeratorHi,
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/P8uGAb8YOctober 2, 2021 at 4:44 AM #31108toni bird
ParticipantHi Long,
Thanks for testing, not sure what was wrong, but it works now, many thanks -
AuthorPosts
Viewing 3 posts - 1 through 3 (of 3 total)
- You must be logged in to reply to this topic.