If the user is not an administrator, I would like to disable a specific field.
I tried that:
function disable_acf_load_field( $field ) {
if( !current_user_can( 'administrator' ) ) {
if (get_field($field['name'], $my_post_id)!="") {
$field['disabled'] = true;
}
}
return $field;
}
add_filter('acf/load_field/name=my_field', 'disable_acf_load_field');
But I get a 500 internal server error!
It looks like I can’t use get_field() inside this load_field filter.
Do you have an idea on how I can get a readonly field if this field has a value already set?
Many thanks!