Fixes #1681 and the annoying empty meta problem.

git-svn-id: http://svn.automattic.com/wordpress/trunk@2887 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
matt 2005-09-16 17:27:09 +00:00
parent dd14bda3ae
commit 195206fbb4
2 changed files with 5 additions and 1 deletions

View File

@ -180,6 +180,8 @@ function wp_insert_post($postarr = array()) {
add_post_meta($post_ID, '_wp_page_template', $page_template, true);
}
do_action('wp_insert_post', $post_ID);
return $post_ID;
}

View File

@ -2047,7 +2047,7 @@ function update_usermeta( $user_id, $meta_key, $meta_value ) {
$meta_value = serialize($meta_value);
$cur = $wpdb->get_row("SELECT * FROM $wpdb->usermeta WHERE user_id = '$user_id' AND meta_key = '$meta_key'");
if ( !$cur ) {
if ( !$cur && !empty( $meta_value ) ) {
$wpdb->query("INSERT INTO $wpdb->usermeta ( user_id, meta_key, meta_value )
VALUES
( '$user_id', '$meta_key', '$meta_value' )");
@ -2055,6 +2055,8 @@ function update_usermeta( $user_id, $meta_key, $meta_value ) {
}
if ( $cur->meta_value != $meta_value )
$wpdb->query("UPDATE $wpdb->usermeta SET meta_value = '$meta_value' WHERE user_id = '$user_id' AND meta_key = '$meta_key'");
if ( empty( $meta_value ) )
$wpdb->query("DELETE FROM $wpdb->usermeta WHERE user_id = '$user_id' AND meta_key = '$meta_key'");
}
function register_activation_hook($file, $function) {