Delete usermeta field if set to empty string. Props David House. fixes #2341
git-svn-id: http://svn.automattic.com/wordpress/trunk@3495 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
cd678d9a32
commit
325a641cac
|
@ -2220,6 +2220,10 @@ function update_usermeta( $user_id, $meta_key, $meta_value ) {
|
||||||
$meta_value = serialize($meta_value);
|
$meta_value = serialize($meta_value);
|
||||||
$meta_value = trim( $meta_value );
|
$meta_value = trim( $meta_value );
|
||||||
|
|
||||||
|
if (empty($meta_value)) {
|
||||||
|
delete_usermeta($user_id, $meta_key);
|
||||||
|
}
|
||||||
|
|
||||||
$cur = $wpdb->get_row("SELECT * FROM $wpdb->usermeta WHERE user_id = '$user_id' AND meta_key = '$meta_key'");
|
$cur = $wpdb->get_row("SELECT * FROM $wpdb->usermeta WHERE user_id = '$user_id' AND meta_key = '$meta_key'");
|
||||||
if ( !$cur ) {
|
if ( !$cur ) {
|
||||||
$wpdb->query("INSERT INTO $wpdb->usermeta ( user_id, meta_key, meta_value )
|
$wpdb->query("INSERT INTO $wpdb->usermeta ( user_id, meta_key, meta_value )
|
||||||
|
|
Loading…
Reference in New Issue