I have tried unsuccessfully to set a field to either “diabled” or “readonly” on a front-end form using either the load_field and prepare_field filter hooks. The picker still funtions and saves the value on submit.
I am confident that my function is working because I can convert the field type to text and it is readonly on the form.
I think this may be a bug related to a Jquery conflict.
Any feedback would be appreciated.
Hey, thanks for the response. I am using a date picker to set date/time on a frontend form by the Admin, but if not Admin I dynamically set the field to read-only for subscriber/user so they can’t change the date. Currently I’ve elected to just use a text field, but the picker function would have been nice.
I don’t really have an easy solution for you.
You can also dynamically change the field type depending on the status of the logged in user, but that’s not likely to help you either since internally dates are stored in the format
YYYYMMDD and showing that in a text field would probably just confuse people.
Another choice is to have two different fields, one for admins and one for everyone else. When the admin updates the value in the admin field you could dynamically populate the other field using an acf/save_post filter (https://www.advancedcustomfields.com/resources/acfsave_post/) and the update_field() function (https://www.advancedcustomfields.com/resources/update_field/). I have recently created a plugin that let’s you create fields for specific user roles. If you didn’t want to use the plugin and just set it up on a single field you can use it as an example. https://github.com/Hube2/acf-user-role-field-setting.
You must be logged in to reply to this topic.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
© 2022 Advanced Custom Fields.