From b9b0e7215c4d13e300de9f336e74213e45701013 Mon Sep 17 00:00:00 2001 From: Ryan Boren Date: Wed, 1 Dec 2010 19:11:47 +0000 Subject: [PATCH] Save meta id before performing actions since the insert_id can change. Props cyberhobo. fixes #15465 git-svn-id: https://develop.svn.wordpress.org/trunk@16659 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-admin/includes/post.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/wp-admin/includes/post.php b/wp-admin/includes/post.php index db947d401a..3269034f30 100644 --- a/wp-admin/includes/post.php +++ b/wp-admin/includes/post.php @@ -641,9 +641,10 @@ function add_meta( $post_ID ) { wp_cache_delete($post_ID, 'post_meta'); $wpdb->insert( $wpdb->postmeta, array( 'post_id' => $post_ID, 'meta_key' => $metakey, 'meta_value' => $metavalue ) ); - do_action( 'added_postmeta', $wpdb->insert_id, $post_ID, $metakey, $metavalue ); + $meta_id = $wpdb->insert_id; + do_action( 'added_postmeta', $meta_id, $post_ID, $metakey, $metavalue ); - return $wpdb->insert_id; + return $meta_id; } return false; } // add_meta