diff --git a/wp-includes/functions-post.php b/wp-includes/functions-post.php index 8681a859e3..d5f7b6122c 100644 --- a/wp-includes/functions-post.php +++ b/wp-includes/functions-post.php @@ -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; } diff --git a/wp-includes/functions.php b/wp-includes/functions.php index 0076239414..fe044eac9e 100644 --- a/wp-includes/functions.php +++ b/wp-includes/functions.php @@ -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) {