I let users create posts and upload/attach images to that post via the frontend. This works fine. However, when I restrict the access to the Wordpress backend (/wp-admin/) via a code snippet like this one
function wpse_11244_restrict_admin() {
if ( ! current_user_can( 'manage_options' ) ) {
wp_die( __('You are not allowed to access this part of the site') );
}
}
add_action( 'admin_init', 'wpse_11244_restrict_admin', 1 );
or (EDIT) with a redirect code
function redirect_non_admin_users() {
if ( ! current_user_can( 'manage_options' ) && '/wp-admin/admin-ajax.php' != $_SERVER['PHP_SELF'] ) {
wp_redirect( home_url() );
exit;
}
}
add_action( 'admin_init', 'redirect_non_admin_users' );
the Media Upload does not work anymore ("Error" Message). This problem has been discussed elsewhere:
I figured out that if the role didn't have that access [to the backend], it also killed their ability to upload files on the front end.
Is there a way to prevent users to access the backend without killing their ability to upload images on the frontend?
Thank you!
/wp-admin/
so you're not messing with permissions.