Site docs are currently being updated 🚧 Thank you for your patience! 🙏

User Roles

ACF Extended
Last Upated: Wednesday, Jan 10, 2024

The User Roles Field Type is a custom ACF Field Type made available by the Advanced Custom Fields Extended plugin.

This field allows for User Role(s) to be selected.

Field Settings

Below you will find information about how various ACF field settings can impact how the field will map to the GraphQL Schema and/or modify resolution of the field when queried.

Field Configuration

<?php
add_action( 'acf/include_fields', function() {
if ( ! function_exists( 'acf_add_local_field_group' ) ) {
return;
}
acf_add_local_field_group(
[
{
"key": "my_field_group_",
"title": "My Field Group with acfe_user_roles",
"show_in_graphql": 1,
"graphql_field_name": "myFieldGroupWithAcfeUserRoles",
"map_graphql_types_from_location_rules": 0,
"graphql_types": [
"Page"
],
"fields": [
{
"key": "my_field_",
"label": "My Field",
"name": "my_field",
"type": "acfe_user_roles",
"show_in_graphql": 1,
"graphql_field_name": "myFieldWithAcfeUserRoles"
}
],
"location": [
[
{
"param": "post_type",
"operator": "==",
"value": "page"
}
]
]
}
]
);
});

Resolve Type

The "User Roles" field type is will return a "List Of User Role" in the GraphQL Schema.

Querying the User Roles field

NOTE: The User Role Type has restrictions and might resolve as null if the requesting user doesn't have proper capabilities to view roles.

Previous
User