I want to attach managers to site customers. I made Entity Reference "user-to-user" and now I want to select users only with role "Managers".

How can I make such filter?

2 Answers 2


As far I understood you want to see only "Managers" in Entity Reference widget on user add/edit page.

Entity reference widget can filter values by using "Views" module.

You can just create an "Entity reference view" and get all users with role "Manager" there.

Here is instruction for widget settings: https://drupal.stackexchange.com/a/38917/6309


Its Good To simple Alter you form, update the field options, Drupal did not provide a simple way to select a user by a role in the entity reference

feedback_form_events_node_form_alter(&$form, $form_state, $form_id) {

if($form_id== 'events_node_form'){

   $form['event'] = array(
    '#type' => 'select',
    '#title' => t('Select Event'),
    '#options' => $event,
    '#required' => TRUE,
    '#prefix' => ' <li class="custom-select">',
    '#suffix' => '</li>',


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.