Skip to content

Instantly share code, notes, and snippets.

@TudorSfatosu
Created May 2, 2023 09:05
Show Gist options
  • Save TudorSfatosu/ad541c12a2aa50e03258458eeb46c305 to your computer and use it in GitHub Desktop.
Save TudorSfatosu/ad541c12a2aa50e03258458eeb46c305 to your computer and use it in GitHub Desktop.
Disabling the editing of an ACF field
<?php
// Disabling the editing of an ACF field
add_filter('acf/load_field', 'my_acf_load_field');
function my_acf_load_field($field) {
// Check if the field is named "event_id"
if ($field['name'] == 'event_id') {
// Set the "readonly" attribute to true
$field['readonly'] = true;
}
return $field;
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment