Custom autocomplete field I am trying to create an autocomplete field for users.  The following code is fine for username searches but the requirement is for a search by any part of the user's first and last name.

$form['user'] = [
  '#type' =&gt; 'entity_autocomplete',
  '#target_type' =&gt; 'user',
  '#selection_settings' =&gt; [
    'include_anonymous' =&gt; FALSE,
  ],
];


I am wondering what the best way to filter by first and last name is.  Is it even possible to use 'entity_autocomplete'?  It doesn't look like any of the EntityAutocomplete class methods would make this possible and I'm not clear on whether or not the '#selection_handler' and '#selection_settings' properties could be helpful.
The selection_handler element property allows to specify a plugin id of a class that would override the default selection handler for EntityAutocompleteMatcher. A separate plugin would be able to build a different Entity Query.

Create a plugin of EntityReferenceSelection type. This should be a derivative of the DefaultSelection plugin similar to TermSelection.

Then you can override entityQueryAlter to add additional conditions to the entity query.