WordPress media upload causes errors when not logged in
-
0
down vote
favorite
I have a button on my site (front-end) that triggers the WordPress Media Uploader, whether or not the user is logged in. It’s basically a guestbook where people can post photos. It works flawlessly if I am logged in as admin, but if I log out and use it, I get an error that simply says: “An error occurred in the upload. Please try again later.”I have done a bunch of reading about this on Google but have found nothing that helps. The thing is, it works great if I am logged in to WordPress.
The files are jpg and only 150k and 300px x 300px.
Here’s the error: https://imgur.com/a/k5ULg
Here’s the jquery that calls the media Uploader:
$('#upload-photo-btn').click(function(e) { var image = wp.media({ title: 'Upload Image', multiple: false }).open() .on('select', function(e){ var uploaded_image = image.state().get('selection').first(); var image_url = uploaded_image.toJSON().url; $('#image_url').val(image_url); $('.thumbnail').css('background-image', "url("+image_url+")"); e.preventDefault(); }); });
I have wp_enqueue_media() called using the ‘wp_enqueue_scripts’ hook in my main plugin file.
What else can be causing this?
- The topic ‘WordPress media upload causes errors when not logged in’ is closed to new replies.