Problem storing arrays with update_user_meta

Haven’t used the function for quite a time, but i guess your problem is that you are pushing an array into an array. So check if intval($_GET['auction']) is an array:

echo '<pre>';
print_r(intval($_GET['auction']));
echo '</pre>';

Edit #1: You maybe need to get the value from that array and then array_push it. So maybe something like array_push( $reminders, $_GET['auction'][0]) ); – if you’re only adding one single value. You could also do something like $reminders[] = $_GET['auction'][0]; to add it to the end of your array.

Edit #2: From a look at the core file: yes. update_user_meta() is just an alias of update_metadata() which takes the ID + the value and puts it into the database as and array.

// From /wp-includes/meta.php ~ line 135
$where = array( $column => $object_id, 'meta_key' => $meta_key );

if ( !empty( $prev_value ) ) {
    $prev_value = maybe_serialize($prev_value);
    $where['meta_value'] = $prev_value;
}

Leave a Comment