Support

Account

Home Forums Feature Requests New Conditional Logic Option: User Role

Solving

New Conditional Logic Option: User Role

  • Would be really handy for some of the more complicated layouts to be able to (sort of) lock fields by not displaying them unless a user is an admin. The logic is there for entire field groups but it would be really handy to have it on field sets.

    My two use cases today:

    1. I need to add a field to create a custom human readable ID for each field. I’m going to hook js/css to this on the front end so I can’t have people messing with it!
    2. I have setup a few pages with flexible content fields but I want to keep them fixed, not flexible! 🙂 I used flexible content fields because it was the easiest way to get a bunch of different sublayouts on a set of different landing pages (that share the same sublayouts but it vastly different orders). I’m hiding the ‘add layout’ button with CSS but that’s hacky!

    Actually, now that I think about it, it could be handy to have a lot of the global fieldset rules on a per field basis. Let’s say I use a gallery field in a few fieldsets and those fieldsets are assigned to different pages/page templates/whatevs. In some instances, the galleries need an extra field to display an HTML header/title. Instead of making two separate fieldsets, I could make one, show it on both pages but only show the HTML title field on specific pages.

    Perhaps this stuff could be written as (and better suited for) a plugin, I’m not sure.

    Thanks for reading!

  • I am 100% on board with this.

    I’ve got clients who need to let their users do things like submit and edit a post. They don’t want that user to be able to feature the post on the front page though, which means rolling my own meta box in functions.php. Not that it’s hard to roll your own metabox with a “manage_options” conditional in a system like WP Alchemy – but boy, it’d sure be convenient if ACF did it natively.

  • I agree, this is a logical idea.

  • I agree, would like to see this feature too!

  • +1 Super reasonable. I am wanting this today (which is why I found this). Has anyone worked a reasonably generic hack for this?

  • @jjrohrer I wound up doing something like this:

    https://gist.github.com/jancbeck/3178689

    to add each user’s role as a classname on the body. Then used an admin style sheet to hide the field.

  • As I think of this, I would really like a hook that asked if a field would display and if it could be saved. That would make it easy for us to a capability check in there, but also to add some other logic.


    @will
    If I understand your gist, it just hides the option, leaving it open to security issues. I think I saw and ‘update’ hook and ‘validation’ hook. Maybe I could force the data always revert to saved state. Sounds super fragile.

  • 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). https://github.com/Hube2/acf-user-role-field-setting. 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.

  • Why isn’t this a feature of ACF?

    ps. The plugin works, thanks!

  • I would also like to see this as a native ACF feature, both:
    – fields hidden for certain (low) user levels
    – fields read only for certain (low) user levels

  • +1, as Andrija puts it:
    – fields hidden for certain user roles
    – fields read only for certain user roles

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

The topic ‘New Conditional Logic Option: User Role’ is closed to new replies.