Home › Forums › Feature Requests › Read-Only Field › Reply To: Read-Only Field
I’ve tried that plugin and it doesn’t seem to run/display AFC’s the_field.
I’ve been playing with trying to use jQuery to disable input, I have it working for the date picker, but no luck on select2.
<?php // Disable AFC fields based on user role/
if( !current_user_can( 'administrator' ) ):
function disable_acf_load_field( $field ) {
$field['disabled'] = true;
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');
//Backend jquery
add_action('admin_print_footer_scripts', 'afc_disable_admin_jquery');
function afc_disable_admin_jquery(){
?>
<script>
jQuery(function(jQuery) {
jQuery(document).ready(function(){
jQuery(".hasDatepicker").prop('disabled', 'disabled');
});
});
</script>
<?php
}
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.