Contributor upload files working from admin panel but not from the page
-
Hi,
I have enabled the upload files for contributors using
$contributor = get_role(‘contributor’);
$contributor->add_cap(‘upload_files’);And uploading images is working from the admin panel > Add New Post > Add Media
But, i am using a method to add media buttons on a page
function show_media_buttons() {
include_once( ABSPATH . ‘/wp-admin/includes/media.php’ );
ob_start();
do_action( ‘media_buttons’ );
$buttons = ob_get_clean();
// Replace any relative paths to media-upload.php
$buttons = preg_replace( ‘/([\'”])media-upload.php/’, ‘${1}’ . admin_url( ‘media-upload.php’ ), $buttons );
// Remove any images.
$buttons = preg_replace( ‘/<img [^>]*src=(\”|\’)(.+?)(\1)[^>]*>/i’, ”, $buttons );
echo $buttons;
}This is working perfectly fine for ADMINS, but for contributor, i see the media manager, but when i try to upload the image, it gives an error
‘An error occurred in the upload. Please try again later.’
Don’t know what is wrong.
Works from admin panel but not from custom page.page url: https://funnychutkule.com/submit/
TIA
- The topic ‘Contributor upload files working from admin panel but not from the page’ is closed to new replies.