• 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

Viewing 1 replies (of 1 total)
  • Thread Starter Ankur Gupta

    (@aglow)

    Worked after i used the function wp_enqueue_media() on my custom page.

    ??

Viewing 1 replies (of 1 total)
  • The topic ‘Contributor upload files working from admin panel but not from the page’ is closed to new replies.