Home › Forums › Bug Reports › DateTimePicker cannot be set to Read Only › Reply To: DateTimePicker cannot be set to Read Only
I don’t really have an easy solution for you.
You could look into adding your own custom JavaScript to try and make the field readonly. The problem is that the version of Select2 used currently in ACF is “Not Aware” of fields being readonly or disabled. I don’t even know if this is solvable.
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.
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!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.