I am trying to insert/update post meta when the user registers. Before writing that action, I am testing this code on the page so whenever the page refresh it will insert/update the post meta.
Question: However, the below code is not inserting/updating anything in post meta. Can anyone tell me what is wrong in this code or how to fix it?
$groupItem = get_post(123);
if ($groupItem && $groupItem->post_type == 'cpt_group') {
$meta = 'group_users';
$user_ids = get_post_meta($groupItem->ID, $meta, TRUE);
if ( ! $user_ids) {
$user_ids = [];
add_post_meta($groupItem->ID, $meta, array_push($user_ids, 26));
} else {
update_post_meta($groupItem->ID, $meta, array_push($user_ids, 26), $user_ids);
}
}