Home › Forums › Backend Issues (wp-admin) › AJAX issue with ACF Javascript › Reply To: AJAX issue with ACF Javascript
Okay, I added a check for wp_doing_ajax() and I no longer get “Loading error…”. I now get “No matches found” when logged in as a user. It works fine when I’m logged in as an admin.
Here is my code:
add_action( 'init', 'am_block_user_from_admin' );
function am_block_user_from_admin() {
if ( wp_doing_ajax() )
exit;
if ( is_admin() && ! current_user_can( 'administrator' ) ) {
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.