Home Forums Backend Issues (wp-admin) Limit editing profile field by user role


Limit editing profile field by user role

  • Hi!

    I’m using ACF to add additional fields to the profile page of WordPress users. How can I add fields to the profile of users of a specific user role, but limit editing these fields to another user role?

    Let’s say I have to user roles:

    • member
    • community manager

    I add fields to the profile of all users of role member by setting the position option of the field group to:

    User form is equal to all AND user role is equal to member

    Now when ever I view the profile form of a user of the role member the fields show up. But I need theses fields to be only shown and editable by users of the role community manager.

    When I set the display rule to user role is equal to community manager then the fields only show up in profile forms when editing users of this role, which is the opposite of what I try to achieve.

    Thx for your help!


  • I know that this is an old question and you may not be looking for help with it any more. But if you are or there are others that are looking for a possible solution to this.

    This might be possible with some creative filtering.

    Please keep in mind that I have not tested any of this, the question just gave me a reason to think about it and how this might possibly be solved because I have a similar situation in which I want to have a checkbox that is a readonly field and that checkbox will be set dynamically and then I’m hoping to have another field with conditional logic based on the checkbox field.

    Anyway, my possible solutions to this:

    1) Create a radio or select field. The choices of this field will be dynamically generated using an acf/load_field filter. The filter function will also set the “read_only” attribute to “1” and set the “value” of the currently logged in user.

    2) Create additional fields that use conditional logic based on the first field and set them to only show if the value of the first field is the user role type you want to allow to edit them.

    Like I said, I don’t know if this will work or not. If anyone tries it I’d love to here how it works out.

  • Hi, just for saying that it worked for me.
    Only one consideration: As we are working with a select field, setting “readonly” as true has no effect, instead you should set “disabled” as true.

  • Thanks for the reply, it’s good to know that it can be done.

  • For anyone that’s looking for something like this, I have created a little add on that adds a user role setting to every field. It’s kind of a big hammer approach to making making fields only available to specific user roles and it only works with ACF5 (Pro). If you only want to do this for some fields rather than all fields it would be easy to use the code ans an example of what needs to be done.

  • Thanks John, I will give it a try in future projects!

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

The topic ‘Limit editing profile field by user role’ is closed to new replies.