Created
January 28, 2022 01:37
-
-
Save drewbaker/64fc9816494ef4c8d6dff1c293f30ff7 to your computer and use it in GitHub Desktop.
Extend WP-GraphQL to allow users/authors to be public. Useful to query all posts by Author.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Extend WP-GraphQL to allow users/authors to be public. Useful to query all posts by Author. | |
*/ | |
function enable_authors_public( $is_private, $model_name, $data, $visibility, $owner, $current_user ) { | |
// Allow Users to be considered publicly queryable | |
if ( 'UserObject' === $model_name ) { | |
return false; | |
} | |
return $is_private; | |
} | |
add_filter( 'graphql_data_is_private', 'enable_authors_public', 10, 6 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment