Created
March 4, 2020 19:31
-
-
Save kellenmace/63fbf756ad316819297d31d9d6d2fcb5 to your computer and use it in GitHub Desktop.
Exclude Super Admins from WPGraphQL Users Queries
This file contains hidden or 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
<?php | |
function filter_super_admin($result, $source, $args, $context, $info, $type_name, $field_key, $field, $field_resolver) { | |
if ( $type_name === 'RootQuery' && $field_key === 'users') { | |
$result['edges'] = array_filter($result['edges'], function($edge) { | |
return !is_super_admin((int)$edge["node"]); | |
}); | |
} | |
return $result; | |
} | |
add_filter( 'graphql_resolve_field', 'filter_super_admin', 10, 9 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment