I need to restrict the access to the dashboard fon non-admin. Therefore i'm using this function in the functions.php:
function ggp_restrict_dashboard_access_function() {
if (!current_user_can('administrator')){
wp_redirect(home_url());
}
}
add_action('admin_init', 'ggp_restrict_dashboard_access_function', 1);
Problem is that because of this, Ajax calls are returning a 301 for non logged in users as well as for logged in non-admin users.
How can i workaround this?