Allow Admins or Other Users to Bypass ACF Required Fields

Quick Summary
- Turn off ACF validation for chosen roles on post edit screens so administrators can save posts with empty required fields.
- A callback on acf/input/admin_head sets window.acf.validation.active to false, and one on acf/validate_save_post calls acf_reset_validation_errors().
- Replace the example's school_administrators role with your own, and note that every ACF validation rule is skipped, not just required fields.
Advanced Custom Fields won’t let you save a post while a required field is empty. Sometimes an administrator needs to save anyway, for example to fix one value on an incomplete record. This snippet turns ACF validation off for chosen user roles on post edit screens, so they can bypass the required fields while everyone else still has to fill them in.
Add it to your theme’s functions.php or a small custom plugin.
add_action('acf/input/admin_head', 'my_acf_admin_head');
function my_acf_admin_head() {
if (!function_exists('get_current_screen')) {
return;
}
// Get current page/screen
$screen = get_current_screen();
// Get current user
$user = wp_get_current_user();
if (is_object($screen) && is_a($screen, 'WP_Screen')) {
if ( ($screen->base == 'post') && ( in_array('administrator', $user->roles) || in_array('school_administrators', $user->roles) )) {
?>
<script type="text/javascript">
window.acf.validation.active = false;
//alert('I AM HERE');
</script>
<?php
}
}
}
add_action('acf/validate_save_post', 'my_acf_validate_save_post', 10, 0);
function my_acf_validate_save_post() {
if (!function_exists('get_current_screen')) {
return;
}
// Get current page/screen
$screen = get_current_screen();
// Get current user
$user = wp_get_current_user();
if (is_object($screen) && is_a($screen, 'WP_Screen')) {
if ( ($screen->base == 'post') && ( in_array('administrator', $user->roles) || in_array('school_administrators', $user->roles) )) {
// clear all errors so they can bypass validation for user data
acf_reset_validation_errors();
}
}
}How the ACF required fields bypass works
Both functions run the same check first: the current admin screen’s base is post, which covers the add and edit screens of posts, pages and custom post types, and the current user has the administrator or school_administrators role.
my_acf_admin_head()runs onacf/input/admin_headand prints a script that setswindow.acf.validation.activetofalse. This turns off ACF’s JavaScript validation, so the browser doesn’t stop the form from being submitted.my_acf_validate_save_post()runs onacf/validate_save_postand callsacf_reset_validation_errors(), which clears the validation errors ACF has collected, so the save goes through.
Adjust it for your site
school_administratorsis a custom role from the original project (see registering a custom user role with add_role()). Replace it with your own role slugs, or remove it.- To limit the bypass to one post type, also check
$screen->post_type. This article on checking which admin screen you’re on shows how the screen object works. - The bypass isn’t limited to required fields. Every ACF validation rule is skipped for these users, so they can also save values that would normally be rejected.
The approach comes from this Stack Overflow question.
If your editors need field rules that fit how they really work, I set them up as part of my custom WordPress development work.
Related articles
- giving an ACF field a default value with acf/load_field: pre-fill a required date so it is never empty
- how I use ACF on custom client sites: the wider case for structured fields editors can’t break
