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.

PHP
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 on acf/input/admin_head and prints a script that sets window.acf.validation.active to false. This turns off ACF’s JavaScript validation, so the browser doesn’t stop the form from being submitted.
  • my_acf_validate_save_post() runs on acf/validate_save_post and calls acf_reset_validation_errors(), which clears the validation errors ACF has collected, so the save goes through.

Adjust it for your site

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.

Share on X (opens in a new tab) Share on LinkedIn (opens in a new tab) Share on Facebook (opens in a new tab)

ChatGPT (opens in a new tab) Claude (opens in a new tab) Gemini (opens in a new tab) Perplexity (opens in a new tab) Grok (opens in a new tab)

More Insights

See More