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;
}
}