Support

Account

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;