[wp-hackers] A question about update_usermeta()

Mike Schinkel mikeschinkel at newclarity.net
Sat Feb 7 16:11:54 GMT 2009

Yeouch. That's pretty much a bug in my mind.

-Mike Schinkel

----- Original Message -----
From: "Steve Johnson" <sj at sawtoothid.com>
To: wp-hackers at lists.automattic.com
Sent: Saturday, February 7, 2009 1:22:19 AM GMT -05:00 US/Canada Eastern
Subject: [wp-hackers] A question about update_usermeta()

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

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

wp-hackers mailing list
wp-hackers at lists.automattic.com

More information about the wp-hackers mailing list