Try:
<?php $user_id = 1234; $metas = array( 'nickname' => $userFirstName, 'first_name' => $userFirstName, 'last_name' => $userLastName , 'city' => $userCityID , 'gender' => $userGenderID ); foreach($metas as $key => $value) { update_user_meta( $user_id, $key, $value ); }
Therefore, instead of passing your array update_user_meta , which takes only string arguments for $meta_key , $meta_key over the array and calls update_user_meta for each key / value pair in the array.
EDIT:
WordPress does not provide an integrated way to update multiple metas simultaneously. Part of the reason for using the built-in function is that filters and hooks can be registered to work with meta-information. They will not be called if you update them directly.
However, you can try something like this (unverified code):
$columns = implode(" = '%s', ", array_keys($metas)) . " = '%s'"; $values = array_values($metas); $values[] = $user_id; $table = _get_meta_table('user'); $sql = "UPDATE $table SET $columns WHERE user_id = %d"; $wpdb->query( $wpdb->prepare($sql, $values) );
source share