Skip to content

Instantly share code, notes, and snippets.

@drewbaker
Created January 28, 2022 01:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save drewbaker/64fc9816494ef4c8d6dff1c293f30ff7 to your computer and use it in GitHub Desktop.
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.
/*
* 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