I need to restrict wp-admin access to all users who cant manage_options and still let users add media on the front end.
function wpse_11244_restrict_admin() {
if ( ! current_user_can( 'manage_options' ) && $_SERVER['PHP_SELF'] != '/wp-admin/admin-ajax.php' ) {
wp_redirect( home_url() );
}
}
add_action( 'admin_init', 'wpse_11244_restrict_admin', 1 );
I found this code on stack overflow and it works great for my disabling the backend. The only hiccup I have found is when I go to add media on a front end post I get the following error.
When I refresh the page and click add media I now see the image that showed the upload error.
The image does upload but the only way the user would know that is if they refreshed.
How can I disable backend access for everything and still allow them to upload media?