Wordpress: There was an error loading

After upgrading to WordPress 3.5, I started getting the following error when uploading files using the Add Media button as a non-admin user:

Error: An error occurred while loading. Please try again later.

The image seems to finish loading, but at the end this error message appears.

This does not happen for the administrator, only for the other roles. I even tried giving other functions full admin capabilities, but the error still appears.

This is mistake? Or am I missing something?

+3


source to share


5 answers


After much trial and error, I finally found a solution that worked for me.

First, I found the following role capabilities required to upload files for custom user roles:

$capabilites = array(

    'read'                  => true,
    'upload_files'          => true,
    'edit_published_pages'  => true,
    'edit_others_pages'     => true

);

      

I'm not sure why this is especially necessary, but the error continued without them.

Second, I had to update the feature I was using to prevent non-admin users from accessing the dashboard:



function redirect_nonadmin_fromdash(){

    if($_SERVER['PHP_SELF'] == '/wp-admin/async-upload.php'){

        /* allow users to upload files */

        return true;

    } else if(get_user_role() != 'administrator'){

        /* custom function get_user_role() checks user role, 
        requires administrator, else redirects */

        wp_safe_redirect(home_url());
        exit;

    }

}

add_action( 'login_form_login', 'redirect_nonadmin_fromdash' );
add_action( 'admin_init', 'redirect_nonadmin_fromdash', 1 );

      

I used to check the media-upload.php file, but the new media uploader uses async-upload.php.

So, in essence, it allows non-admin users to use the new media uploader from the front-end without giving them dashboard access.

It also restricts their access to the Media Library, which is also important to me.

+8


source


This can be caused by several different factors, which usually involve the following:

The file will be large

Check out this thread on how to maximize file size resolution.

Insufficient disk space



Make sure your hard drive hard drive is full.

Insufficient write rights

Make sure PHP and your web server have write access to the wp-uploads folder.

+1


source


I had this error after upgrading PHP to 5.3. The problem I had was short_open_tag.

It is disabled by default. I turned it on and now everything is fine.

+1


source


I solve my problem with

sudo apt-get update
sudo apt-get install php5-gd

      

this is the message I get in firebug check at boot time.

   GD Library Error: imagecreatetruecolor does not exist - please contact your webhost and ask them to install the GD libraryGD Library Error: imagecreatetruecolor does not exist - please contact your webhost and ask them to install the GD library{"success":true,"data":{"id":17,"title":"yoshi","filename":"yoshi1.jpg"

      

so I am getting this in firebug at boot time.

0


source


See this link for more details - I was helped https://sebastian.expert/fix-wordpress-an-error-occurred-in-the-upload-please-try-again-later/

Basically what he says is to use the developer tools in Chrome or Firefox to see the response from the async_upload.php file after uploading the files (when the error appears). It returns error data in JSON format. Having the details will make it easier and much faster for you to solve the problem.

0


source







All Articles