• I have WP MU and I have a page on main domain from where blog admins can update/manage their pages/posts. so it looks like: http://www.MainDomain.com/members On that page I am check if user is blog admin and I am gathering infos I need and doing this:

    switch_to_blog($userblog_id);
    wp_enqueue_script('post');
    wp_enqueue_media( array( 'post' => $post_id ) );
    wp_editor( $post_content, 'post_content', $settings = array(textarea_rows => 15, media_buttons => true) );

    $userblog_id is actually ID of the blog that user is assigned to. $post_id is ID of the post that user is editing on member page.

    Now when blog admin clicks on Upload Media button it shows media upload popup, but the media gallery is always empty and when admin tried to upload something it is always failing with this error “An error occurred in the upload. Please try again later.”

    I saw that MainDomain.com/wp-admin/admin-ajax.php is called when I click Add Media button and that json response is: {“success”:false}

    Now when I am logged in as superadmin – it works properly.

    Does anybody have an idea what’s wrong here ?

Viewing 15 replies - 1 through 15 (of 17 total)
  • Thread Starter peterbra

    (@peterbra)

    ..Forgot to mention when I go to the site dashboard for that blog and click Add media button – admin-ajax.php response is :
    {“wp-auth-check”:true,”wp-refresh-post-lock”:{“new_lock”:”1386087028:4″},”server_time”:1386087028}

    So obviously even if I am logged in as blog admin on main site – I am not getting authenticated as blog admin when ajax request is run on MainDomain.com ? Is there a work-around ?

    Moderator Ipstenu (Mika Epstein)

    (@ipstenu)

    🏳️‍🌈 Advisor and Activist

    I have WP MU and I have a page on main domain from where blog admins can update/manage their pages/posts.

    Just to be clear… are they editing their pages/posts on OTHER SITES or on the main domain?

    Thread Starter peterbra

    (@peterbra)

    They are editing their own pages/posts (mine setup is only one username/admin per blog).It’s subdomain setup, so I guess it may be some kind of domain policy issue when they have to upload from “main domain” members page ? I am not sure if switch_to_blog($userblog_id) is working properly when ajax calls are running ? And i’m not that good in Ajax 🙁

    Moderator Ipstenu (Mika Epstein)

    (@ipstenu)

    🏳️‍🌈 Advisor and Activist

    If a user isn’t added to a site (blog) then they can’t post TO that blog, hence my asking if they’re posting to site #1 (the main site) or their own.

    Thread Starter peterbra

    (@peterbra)

    OK, I see your point 🙂 Do you have any ideas why ajax isn’t authenticating requests ?

    My wild guess is that it’s ajax/same domain policy issue ? I am doing switch_to_blog() call and that part is ok (like post/page are updating etc…), but since that call is coming from http://www.MainDomain.com/members and is trying to upload to blog.MainDomain.com I guess that in that part the conflict occurs (for ajax http://www.MainDomain.com and blog.MainDomain.com are completely different domains) – am I right ?

    Moderator Ipstenu (Mika Epstein)

    (@ipstenu)

    🏳️‍🌈 Advisor and Activist

    maindomain.com and sub.maindomain.com are separate domains and require separate cookies. maindomain.com/sub would be able to use the same cookies and not require re-authentication, so that’s certainly going to be a problem.

    Thread Starter peterbra

    (@peterbra)

    Well, that’s the thing I’m confused with – all users (and user is blog admin as I have only one user per blog and that user is blog admin), so all admins are also logging via http://www.MainDomain.com/login and all cookies are set there.

    I know all cookies are good because after login on main site I can go to subdomain.MainDomain.com/wp-admin and I am logged-in as admin, and from there I can use wp normally ( wp uploader as well 🙂 )

    Only issue I have is with media uploader on main blog (MainDomain.com/members is location) -> how to “explain” to that ajax call that user is admin and that he is logged in and that all is OK as it seems to me that ajax can’t figure out that user is legit – hence it’s denying access 🙁

    Moderator Ipstenu (Mika Epstein)

    (@ipstenu)

    🏳️‍🌈 Advisor and Activist

    Unless you set up cookieless domains, or cross-domain permissions, it’s not actually working the way you think it is.

    Cookies are not shared between subdomains. Browsers don’t let you. You’re actually logged in twice, once on each domain/subdomain.

    Thread Starter peterbra

    (@peterbra)

    Well – I’m not sure what’s best to do as I’m new to WP MU – can you point me in right direction now ? What should I do to make this uploader work with setup I have… How do I alter cross-domain policy ?

    Moderator Ipstenu (Mika Epstein)

    (@ipstenu)

    🏳️‍🌈 Advisor and Activist

    Best? Let people actually use WordPress as intended. Let them go in and edit their sites like they are what they are: Separate sites.

    Second Best would be to go to each site to have the per-site uploader/front end writer you seem to have crafted.

    But this is based on the very limited explanation of ‘why’ you’ve given, that is to say you have not explained why you want to do this 🙂 Believe it or not, understanding why you’re doing something, the purpose of the end goal, may help people find workarounds.

    Thread Starter peterbra

    (@peterbra)

    Well, I wouldn’t be bothering my self to do something if I don’t have to, right 🙂

    The goal is that all admins will go to one page on my main domain and manage their respective sites from there. They won’t have that many options as they have in WP – only basics one like: write page/post and delete/edit, create category and upload media to the post, change profile info and that’s about it.

    Anyway – I couldn’t find the right solution for this, so I’ll just write my own media uploader…

    Moderator Ipstenu (Mika Epstein)

    (@ipstenu)

    🏳️‍🌈 Advisor and Activist

    What if I told you there were plugins that would, on wp-admin, limit them to just being able to write posts, create categories, and upload media? So instead of reinventing the wheel, you could lock things down?

    Mind you … why do you want them to not have that access and own their own sites? With Multisite, that’s way overkill. What do they actually need separate SITES for if they’re not using them as admins?

    Thread Starter peterbra

    (@peterbra)

    Hi Ipstenu and thanks for your time helping me out, but my users are mostly elderly people or people with no computer experience what-so-ever, and I really have to make this system easy to use.

    I did more than 100 WP sites – never did the MU – this is my first one so I know that there are a lot of plugins and I can use roles and stuff – I know all that, but this is the road i have to go – my custom backend on main site, and I am almost done 🙂

    I am kind of baffled that there is no work-around to solve ajax cross-domain media-uploader issue.

    Once again thanks for your time and effort – I appreciate it 🙂

    Moderator Bet Hannon

    (@bethannon1)

    I had a similar situation with a very tech-averse client, and to keep things super-simple for him, I created a password protected page for him with a Gravity form where he could input his posts without freaking out on the dashboard.

    Gravity Forms allows you to use Post Fields, where the entries can be automatically assembled into posts–including title, body, tags, categories & images.

    What if you did that on your main site, then set up notification emails through the Gravity routing feature (based on their inputted email or a username) to post to the correct subsite, using WP’s post-by-email feature?

    Complex, but keeps your users calm?

    Moderator Ipstenu (Mika Epstein)

    (@ipstenu)

    🏳️‍🌈 Advisor and Activist

    Post-By-Email and Multisite aren’t the best of friends.

    Why can’t they go to their own special page per site, though? I mean, you would reduce your complexity just by saying ‘To post on example.com/foo, go to example.com/foo/posthere’ and so on.

Viewing 15 replies - 1 through 15 (of 17 total)
  • The topic ‘Media Uploader issue’ is closed to new replies.