Home › Forums › Backend Issues (wp-admin) › Filter acf/load_field to Disable Fields not working in User Profile › Reply To: Filter acf/load_field to Disable Fields not working in User Profile
To test I commented out the loop and if check, so my code was:
function tgmembership_modify_acf_field_on_load( $field ) {
// get plugin settings
$options = get_option( 'tgmembership_options' );
// get names of fields that should be read-only
$readonly_fields = array_map('trim', explode(",", $options["acf_readonly"]));
// loop each readonly slug and set the disabled flag on those fields
//foreach ($readonly_fields as $name) {
//if ($field["name"] == $name) {
$field['disabled'] = 1;
// }
//}
// return the field
return $field;
}
add_filter('acf/load_field', 'tgmembership_modify_acf_field_on_load', 16);
It boils down to being the same as your test. It still left the fields enabled. I set Xdebug breakpoints on the $field['disabled'] = 1;
and return $field;
lines. These let me verify that indeed disabled
was getting set to 1
. Yet still the fields are enabled on the User Profile page. I believe you that your test disabled the fields. I just don’t understand why the same isn’t happening in my code…
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.