Support

Account

Home Forums Backend Issues (wp-admin) Set fields to readonly based on user-role in wp-admin Reply To: Set fields to readonly based on user-role in wp-admin

  • It is not possible to set every field type in ACF to read only, at least I’m pretty sure that it’s not possible. It really depends on the type of field it is. The fields types that use Select2 are the most problematic.

    If it can be done you would do this using a prepare field filter on each field https://www.advancedcustomfields.com/resources/acf-prepare_field/. In this filter you would need to see if the post is a new post of not (post_type = “auto-draft”) and then you’d need to check the user role. Depending on these, some of the fields can be set to read only by

    
    $field['readonly'] = 1;
    

    Some fields you’d need to use the disabled propery

    
    $field['disabled'] = 1;
    

    and some fields you’d need to research and probably us custom javascript. I don’t begin to know how to do this with the select2 fields.