Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Two fixes related to checking whether the user has access to modifyin…

…g the post.

* If the $user_id isn't set, the user is never an author of the post
* Check whether the user is logged in before considering whether to modify caps
  • Loading branch information...
commit f903ac8d292873446c818a8ade47f0e4ee8d6458 1 parent ec82661
@danielbachhuber danielbachhuber authored
Showing with 4 additions and 1 deletion.
  1. +1 −1  co-authors-plus.php
  2. +3 −0  template-tags.php
View
2  co-authors-plus.php
@@ -1062,7 +1062,7 @@ function filter_user_has_cap( $allcaps, $caps, $args ) {
return $allcaps;
// We won't be doing any modification if they aren't already a co-author on the post
- if( ! is_coauthor_for_post( $user_id, $post_id ) )
+ if( ! is_user_logged_in() || ! is_coauthor_for_post( $user_id, $post_id ) )
return $allcaps;
$current_user = wp_get_current_user();
View
3  template-tags.php
@@ -49,6 +49,9 @@ function is_coauthor_for_post( $user, $post_id = 0 ) {
$post_id = $post->ID;
if( ! $post_id )
return false;
+
+ if ( ! $user )
+ return false;
$coauthors = get_coauthors( $post_id );
if ( is_numeric( $user ) ) {
Please sign in to comment.
Something went wrong with that request. Please try again.