Skip to content

Instantly share code, notes, and snippets.

@emre-edu-tech
Last active October 13, 2024 06:06
Show Gist options
  • Save emre-edu-tech/1b2d1dadad9664ff06b513a5ad6d47b3 to your computer and use it in GitHub Desktop.
Save emre-edu-tech/1b2d1dadad9664ff06b513a5ad6d47b3 to your computer and use it in GitHub Desktop.
Making an ACF field readonly to prevent the users to enter a value.
<?php
// Make Custom Field Readonly
function make_price_field_readonly($field) {
$field['readonly'] = true;
return $field;
}
// price_field_name is the slug of the Custom Field
add_filter('acf/prepare_field/name=price_field_name', 'make_price_field_readonly');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment