mirror of
https://github.com/WordPress/WordPress.git
synced 2025-01-09 18:08:09 +01:00
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:
parent
72650ed6b7
commit
f588d966bd
@ -269,6 +269,21 @@ function map_meta_cap($cap, $user_id) {
|
|||||||
$caps[] = 'edit_published_posts';
|
$caps[] = 'edit_published_posts';
|
||||||
}
|
}
|
||||||
break;
|
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:
|
default:
|
||||||
// If no meta caps match, return the original cap.
|
// If no meta caps match, return the original cap.
|
||||||
$caps[] = $cap;
|
$caps[] = $cap;
|
||||||
|
@ -643,8 +643,8 @@ class WP_Query {
|
|||||||
} else {
|
} else {
|
||||||
$this->is_preview = true;
|
$this->is_preview = true;
|
||||||
}
|
}
|
||||||
} elseif ('private' == $status) {
|
} else {
|
||||||
if ($this->posts[0]->post_author != $user_ID)
|
if (! current_user_can('read_post', $this->posts[0]->ID))
|
||||||
$this->posts = array();
|
$this->posts = array();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user