How do I get a list of users of a specified role to populate a select list in node/add/* ?

For example when creating a piece of content I want a field "Select Your Moderator of Choice" and the options are a list of all users with the role moderator.

3 Answers 3


For Drupal 8 - You can add a new field to whatever content type you want to capture the User.

Add a User Reference Field

enter image description here

Set the number values allowed

enter image description here

Set the filter to User Role and specify the role:

enter image description here

  • This answer is for D8, while the question is about D7 ... Nov 4, 2016 at 7:31

You will want to install a module that allows you to reference a user. A popular choice is entityreference.

With Entity Reference you can create a view of User's with a display type of Entity Reference. You can then add a filter to your view to only show users with the role that you are interested in.

Then you can setup a new field on your content type of the type, reference. Within that fields settings you can specify your view to be used as the mode for "Entity Selection".

You only need to setup the view if you want to limit the users that are selectable. If any user would be valid for your field, Entity Reference has some built in modes for entity selection that makes the process even easier.


Step 1

To have such a list of users that can be referenced, you should first (repeat: first) create a view (with the Views module) to create a list of all the users that are allowed to be selected. And the display type of such view must be an Entity Reference display.

Step 2

Your select list field (to select from a filtered list of users) should be a field that looks like so:

  • Field Name = Anything you want, eg field_users_list.
  • Field Type = Entity Reference, using these additional settings for it:

    • Target type = user
    • Number of values = 1 (probably, though something like "unlimited may do as well).
    • "Mode" (within "entity selection") = Views: Filter by an entity reference view. However, before you can select an appropriate view at this point (which is eligible to do so), you first need to create a view with an Entity Reference display, or add such a display to an existing view. In your case, you should select the view created in "Step 1".
    • Pick any of the other options to define this field as you see fit.
  • Requires the Entity Reference Module?
    – Sam
    Feb 10, 2017 at 5:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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