Home › Forums › Feature Requests › Read-Only Field › Reply To: Read-Only Field
I have this working for the most part, all of my fields are disabled except for the start_date & end_date fields, those are the type “Date Picker” and the pi_contact is the type of “Post Object”.
Any ideas?
Also would is it possible to pass an array of fields to disable as list, or is using an add_filter required for each?
if( !current_user_can( 'administrator' ) ):
function disable_acf_load_field( $field ) {
$field['disabled'] = 1;
return $field;
}
add_filter('acf/load_field/name=project_code', 'disable_acf_load_field');
add_filter('acf/load_field/name=project_type', 'disable_acf_load_field');
add_filter('acf/load_field/name=project_status', 'disable_acf_load_field');
add_filter('acf/load_field/name=funding_year', 'disable_acf_load_field');
add_filter('acf/load_field/name=start_date', 'disable_acf_load_field');
add_filter('acf/load_field/name=end_date', 'disable_acf_load_field');
add_filter('acf/load_field/name=state', 'disable_acf_load_field');
add_filter('acf/load_field/name=project_primary_institution', 'disable_acf_load_field');
add_filter('acf/load_field/name=pi_contact', 'disable_acf_load_field');
endif;
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.