Some sanity checks -- make sure we have a valid post author user object before checking if the current user is the author.
git-svn-id: https://develop.svn.wordpress.org/trunk@14782 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
3dd5d1edd4
commit
43d4f742b9
@ -835,7 +835,7 @@ function map_meta_cap( $cap, $user_id ) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// If the user is the author...
|
// If the user is the author...
|
||||||
if ( $user_id == $post_author_data->ID ) {
|
if ( is_object( $post_author_data ) && $user_id == $post_author_data->ID ) {
|
||||||
// If the post is published...
|
// If the post is published...
|
||||||
if ( 'publish' == $post->post_status ) {
|
if ( 'publish' == $post->post_status ) {
|
||||||
$caps[] = 'delete_published_posts';
|
$caps[] = 'delete_published_posts';
|
||||||
@ -871,7 +871,7 @@ function map_meta_cap( $cap, $user_id ) {
|
|||||||
$page_author_data = $author_data;
|
$page_author_data = $author_data;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( $user_id == $page_author_data->ID ) {
|
if ( is_object( $page_author_data ) && $user_id == $page_author_data->ID ) {
|
||||||
// If the page is published...
|
// If the page is published...
|
||||||
if ( $page->post_status == 'publish' ) {
|
if ( $page->post_status == 'publish' ) {
|
||||||
$caps[] = 'delete_published_pages';
|
$caps[] = 'delete_published_pages';
|
||||||
@ -906,7 +906,7 @@ function map_meta_cap( $cap, $user_id ) {
|
|||||||
$post_author_data = get_userdata( $post->post_author );
|
$post_author_data = get_userdata( $post->post_author );
|
||||||
//echo "current user id : $user_id, post author id: " . $post_author_data->ID . "<br />";
|
//echo "current user id : $user_id, post author id: " . $post_author_data->ID . "<br />";
|
||||||
// If the user is the author...
|
// If the user is the author...
|
||||||
if ( $user_id == $post_author_data->ID ) {
|
if ( is_object( $post_author_data ) && $user_id == $post_author_data->ID ) {
|
||||||
// If the post is published...
|
// If the post is published...
|
||||||
if ( 'publish' == $post->post_status ) {
|
if ( 'publish' == $post->post_status ) {
|
||||||
$caps[] = 'edit_published_posts';
|
$caps[] = 'edit_published_posts';
|
||||||
@ -934,7 +934,7 @@ function map_meta_cap( $cap, $user_id ) {
|
|||||||
$page_author_data = get_userdata( $page->post_author );
|
$page_author_data = get_userdata( $page->post_author );
|
||||||
//echo "current user id : $user_id, page author id: " . $page_author_data->ID . "<br />";
|
//echo "current user id : $user_id, page author id: " . $page_author_data->ID . "<br />";
|
||||||
// If the user is the author...
|
// If the user is the author...
|
||||||
if ( $user_id == $page_author_data->ID ) {
|
if ( is_object( $page_author_data ) && $user_id == $page_author_data->ID ) {
|
||||||
// If the page is published...
|
// If the page is published...
|
||||||
if ( 'publish' == $page->post_status ) {
|
if ( 'publish' == $page->post_status ) {
|
||||||
$caps[] = 'edit_published_pages';
|
$caps[] = 'edit_published_pages';
|
||||||
@ -970,7 +970,7 @@ function map_meta_cap( $cap, $user_id ) {
|
|||||||
|
|
||||||
$author_data = get_userdata( $user_id );
|
$author_data = get_userdata( $user_id );
|
||||||
$post_author_data = get_userdata( $post->post_author );
|
$post_author_data = get_userdata( $post->post_author );
|
||||||
if ( $user_id == $post_author_data->ID )
|
if ( is_object( $post_author_data ) && $user_id == $post_author_data->ID )
|
||||||
$caps[] = 'read';
|
$caps[] = 'read';
|
||||||
else
|
else
|
||||||
$caps[] = 'read_private_posts';
|
$caps[] = 'read_private_posts';
|
||||||
@ -985,7 +985,7 @@ function map_meta_cap( $cap, $user_id ) {
|
|||||||
|
|
||||||
$author_data = get_userdata( $user_id );
|
$author_data = get_userdata( $user_id );
|
||||||
$page_author_data = get_userdata( $page->post_author );
|
$page_author_data = get_userdata( $page->post_author );
|
||||||
if ( $user_id == $page_author_data->ID )
|
if ( is_object( $page_author_data ) && $user_id == $page_author_data->ID )
|
||||||
$caps[] = 'read';
|
$caps[] = 'read';
|
||||||
else
|
else
|
||||||
$caps[] = 'read_private_pages';
|
$caps[] = 'read_private_pages';
|
||||||
|
Loading…
Reference in New Issue
Block a user