Values not saving in Page

I have added check-boxes in Page and it works when there is only one user (administrator).

As soon as i added more users (including Administrators and other roles), the values do not get saved into the database.

Even when I log in with the first user, it does not work.
So I monitor the database, I check some check-boxes and click update to save the page. The check-box values were saved for a short moment then it was updated with null value.
I am not sure what is resetting the value.
And the weird thing is that happens only when i have more than one user.
If there’s only one user, everything works fine.

I am new to WordPress so I maybe doing wrong somewhere in my code.
This is my code for showing and saving check-box values and
it is in functions.php under the custom theme folder.

add_action(“add_meta_boxes”, “add_product_table_header_list”);

function add_product_table_header_list() {
“Product Table Headers”,

function add_product_table_header_list_render($post) {
global $post;
$post_product_headers = get_post_meta($post->ID, “product_table_headers”, null);
$post_product_headers = empty($post_product_headers) ? array() : json_decode($post_product_headers[0], true);
if (!is_array($post_product_headers)) {
$post_product_headers = [];
$product_table_header_list = n_product_table_header_list();

$outputHtml = “<div class=’_row’>”;
foreach ($product_table_header_list as $product_number) {
$outputHtml .= ‘<div class=”_col-half”><input id=”cb’ . $product_number . ‘” type=”checkbox” name=”product_table_headers[]” value=”‘ . $product_number . ‘” ‘ . (in_array($product_number, $post_product_headers) ? ‘checked’: ”) . ‘ /><label for=”cb’ . $product_number . ‘”>’ . $product_number . ‘</label></div>’;
$outputHtml .= “</div>”;
echo $outputHtml;

add_action(“save_post”, “add_product_header_list_post”);

function add_product_header_list_post($post_id) {
update_post_meta($post_id, “product_table_headers”, json_encode($_POST[‘product_table_headers’]));

function n_product_table_header_list() {
$product_data = get_option(“kinetic_products”, “”);

if (empty($product_data)) {
return array();
// else

$product_data = json_decode($product_data);
return $product_data[0];

$product_number_list = array();
// starts from row 2 as 0, 1 are header rows
for ($x=2; $x<count($product_data); $x++) {
$part_number = $product_data[$x][0];
$product_number_list[$part_number] = “1”;


return array_keys($product_number_list);

Read more here:: Values not saving in Page

Leave a Reply

Your email address will not be published. Required fields are marked *