Skip to content

Commit

Permalink
add the filter to User::is_private() so users can choose to bypass or…
Browse files Browse the repository at this point in the history
… modify this functionality (relates to issue #961)
  • Loading branch information
Zac Scott committed Jan 15, 2021
1 parent 91e1249 commit 96c50e4
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/Model/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,26 @@ public function tear_down() {
*/
protected function is_private() {

/**
* Filter whether the user is private.
*
* If true, the user will be considered private without further checks.
*
* @param mixed|null|boolean $is_private If set, return without executing the manual query
* to see if the user has published posts.
* @param User $this Instance of the User Model
*/
$is_private = apply_filters( 'graphql_user_model_is_private', null, $this );

/**
* If the filter returns true, we can return now as the user is considered private.
*
* Otherwise we need to continue and check if the User should be considered private or not
*/
if ( null !== $is_private ) {
return (bool) $is_private;
}

if ( ! current_user_can( 'list_users' ) && false === $this->owner_matches_current_user() ) {

/**
Expand Down

0 comments on commit 96c50e4

Please sign in to comment.