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
Ensuring that the filter priority was more than 10 didn’t fix the problem. Here is the full code for the filter:
/**
* Modify fields on load based on our advanced settings
*/
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);
I really think that ACF just isn’t respecting the disabled
flag when adding fields to the User Profile. If that is the case then maybe I just can’t use ACF for the fields I want read-only (there are a few others I need to do manually anyway as they’re more complex, so that wouldn’t be a real problem). But I’d consider that a bug in ACF.
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.