From 5f9ac8a5fdaaf395422e8937caa30a085756e583 Mon Sep 17 00:00:00 2001 From: westi Date: Sun, 18 Oct 2009 12:06:39 +0000 Subject: [PATCH] Ensure we always have author info to check capabilities with. Fixes notice on Add new post page. git-svn-id: http://svn.automattic.com/wordpress/trunk@12053 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/capabilities.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/wp-includes/capabilities.php b/wp-includes/capabilities.php index c461e926fc..1e963cb95c 100644 --- a/wp-includes/capabilities.php +++ b/wp-includes/capabilities.php @@ -778,8 +778,14 @@ function map_meta_cap( $cap, $user_id ) { $args = array_merge( array( 'delete_page', $user_id ), $args ); return call_user_func_array( 'map_meta_cap', $args ); } - $post_author_data = get_userdata( $post->post_author ); - //echo "current user id : $user_id, post author id: " . $post_author_data->ID . "
"; + + if ('' != $post->post_author) { + $post_author_data = get_userdata( $post->post_author ); + } else { + //No author set yet so default to current user for cap checks + $post_author_data = $author_data; + } + // If the user is the author... if ( $user_id == $post_author_data->ID ) { // If the post is published...