I had been using a plugin called “Easy Author Image” to display and upload images as profile picture. This plugin actually triggers the “meta-upload.php” file in “wp-admin”. When I log-in as admin in my frontend and upload a file, it works perfectly fine but when I tried using a non-admin role it didn’t allow me to access the upload page. I tried the following code but still it didn’t work.
function allow_nonadmin_uploads() {
if ( current_user_can('contributor') && !current_user_can('upload_files') ){
$jobseeker = get_role('contributor');
$jobseeker->add_cap('upload_files');
}
}
add_action('admin_init', 'allow_nonadmin_uploads');
add_action('init', 'allow_nonadmin_uploads');