Ok, found a way to do this - this is a way to do it for the User screen, it may differ for other post types.
We not only have to disable server side validation, but also client side validation, to do this, we do something a little like this:
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) and is_a($screen, 'WP_Screen')) {
if (($screen->id == 'user-edit' or ($screen->id == 'user' and $screen->action == 'add')) and in_array('administrator', $user->roles)) {
?>
<script type="text/javascript">
window.acf.validation.active = false;
</script>
<?php
}
}
}
This will add some Javascript to any page that matches our qualifers to disable ACF client-side validation.
Now, to disable backend validation, we do something like this:
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) and is_a($screen, 'WP_Screen')) {
if (($screen->id == 'user-edit' or ($screen->id == 'user' and $screen->action == 'add')) and in_array('administrator', $user->roles)) {
// clear all errors so they can bypass validation for user data
acf_reset_validation_errors();
}
}
}
Note that because get_current_screen()
isn't always available, these methods do not support front end forms.
Also note that this code could definitely be improved to be a lot more DRY, but I will leave that up to you. :)