Home › Forums › ACF PRO › acf_form front-end validation conflict using wp_redirect() to restrict back end › Reply To: acf_form front-end validation conflict using wp_redirect() to restrict back end
acf/validate_save_post fires twice, the first is during an AJAX request to validate fields. During AJAX requests is_admin()
is always true. You need to add a test for this
add_action( 'init', 'blockusers_init' );
function blockusers_init() {
if ( is_admin() && check_role('mycustomrole') &&
(!defined(DOING_AJAX) || !DOING_AJAX)) {
wp_redirect( home_url() );
exit;
}
}
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.