Home Forums General Issues ACF User Field – Hide user roles from dropdown


ACF User Field – Hide user roles from dropdown

  • I have a community website with frontend posting using ACF Forms. When a user creates a new post, I want them to be able to select another user on the network as a contributor, or co-writer for that post.

    I have this working perfectly so far, and a user can use the ‘User’ field that’s set up as a multi select. I also have the user object rendering on the frontend which is great.

    The only issue is on the dropdown, I can see a list of user roles that are assigned to that person. For security purposes, I would like it to show only users, and not user roles.

    Currently it shows:

    - User 1
    - User 2
    - User 3
    - User 4

    I would like it to show:

    - User 1
    - User 2
    - User 3
    - User 4

    I have read up on the user field and studied the settings, and I cannot see a way to disable this. How would I go about removing the user role from the dropdown field?

  • There isn’t any way to remove that in ACF. ACF returns a flat array only when searching or when when only searching a single role (or the user query only returns a single role).

    The only way that this could possibly be accomplished would be to assign users that should appear to multiple roles and selecting to only show uses in a specific role.

  • I was worried that may be the case. I have limited it to user role, and used some CSS to hide the Role name from the dropdown.

    .select2-container--default .select2-results__group {
      display: none !important;
  • Hi there,

    Aside of it being a security issue (where anyone who has access to the “ACF user field” knows which role other users belong to) this field is not working as good as you might think.
    We’re developing plugin for WP which defines new roles (e.g. priv-subscriber, priv-editor, priv-admin) where we give WP users multiple roles to be able to access different parts of our ecosystem. So right now with 100 registered users (where each of them can have multiple roles like “editor” plus “priv-subscriber” plus “priv-editor”) each of them is repeated twice or three times.

    Can’t we have user field where users are not listed under their roles and not repeated?

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.