Add read_post meta cap.

git-svn-id: http://svn.automattic.com/wordpress/trunk@3297 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan 2005-12-13 00:54:52 +00:00
parent 72650ed6b7
commit f588d966bd
2 changed files with 17 additions and 2 deletions

View File

@ -269,6 +269,21 @@ function map_meta_cap($cap, $user_id) {
$caps[] = 'edit_published_posts';
}
break;
case 'read_post':
$post = get_post($args[0]);
if ( 'private' != $post->post_status ) {
$caps[] = 'read';
break;
}
$author_data = get_userdata($user_id);
$post_author_data = get_userdata($post->post_author);
if ($user_id == $post_author_data->ID)
$caps[] = 'read';
else
$caps[] = 'read_private_posts';
break;
default:
// If no meta caps match, return the original cap.
$caps[] = $cap;

View File

@ -643,8 +643,8 @@ class WP_Query {
} else {
$this->is_preview = true;
}
} elseif ('private' == $status) {
if ($this->posts[0]->post_author != $user_ID)
} else {
if (! current_user_can('read_post', $this->posts[0]->ID))
$this->posts = array();
}
}