[wp-hackers] A question about update_usermeta()

Steve Johnson sj at sawtoothid.com
Sat Feb 7 06:22:19 GMT 2009


I fought with this for an hour before I finally figured out what was going
on.

I was trying to store a zero 0 value in user_meta table using
update_usermeta(), and the metadata wasn't being created. After diving into
the function in user.php:

	function update_usermeta( $user_id, $meta_key, $meta_value )

I find that the function is evaluating the passed $meta_value using
if(empty($meta_value)). If empty, the metadata is removed. If not empty,
$meta_value is maybe_serialized, then stored.

0 evaluates to empty. String '0' evaluates as empty.

Is this something that should be fixed, or should I just not try to store
the value 0? 


Steve Johnson



More information about the wp-hackers mailing list