Created
May 2, 2023 09:05
-
-
Save TudorSfatosu/ad541c12a2aa50e03258458eeb46c305 to your computer and use it in GitHub Desktop.
Disabling the editing of an ACF field
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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