Support » Plugin: WordPress MU Domain Mapping » Links from Frontend to Backend always end at dashboard

  • Using 0.5.4.3, and recently upgraded several networks to WordPress 4.0 (from 3.8.x), and we are now experiencing the following issue on ONLY those sites which are domain mapped.

    Consider the site at mydomain.com/foo mapped as mysite.com

    When clicking a link from the frontend that should take you to a specific page in the backend (such as Edit Page or Edit Post in the top bar, or the link to go to the Comments screen), you end up at the dashboard instead of at the specific post edit screen. You first make a quick stop at the following URL (I’ve un-escaped it for readability):

    https://mysite.com/wp-login.php?redirect_to=https://mysite.com/wp-admin/post.php?post=26&action=edit&reauth=1

    Our Domain Mapping settings are as follows:
    Remote Login – ON
    Permanent Redirect – ON
    User Domain Page – OFF
    Redirect admin pages.. – ON
    Disable primary domain check – OFF

    Any ideas on what might be causing this, or something we could do to dig deeper and provide more info?

    Thanks as always!

    https://wordpress.org/plugins/wordpress-mu-domain-mapping/

Viewing 6 replies - 1 through 6 (of 6 total)
  • Some updates on this:
    I found that if I disable Remote Login, the links work again. Yay. However, Remote Login was a very nice feature to have!

    I tried turning OFF redirect admin pages, thinking I could turn Remote Login back on and see if that config worked, but it actually won’t let me do that. I kept checking the Remote Login box and submitting, and the form kept reloading with that box unchecked. Ironically, when I turned Reidrect Admin Pages back on, then I could check Remote Login again.

    I believe the most likely culprit of the changed behavior is this: https://core.trac.wordpress.org/ticket/10267

    We WERE using force_ssl_login, but that has now been automatically expanded to a fully SSL admin.

    While this problem existed on 3 separate networks with these settings, the problem has now disappeared from those 3 networks after mucking with the settings for a while and restoring them to their original setting. So, I’ll call this resolved (even though I still have no idea what was going wrong or how exactly it got fixed).

    Cheers 🙂

    Forgive the constant barrage of posts here. While things seemed to be working well, they’re not working actually nearly as well as I’d thought. The problems have returned. I’ll need to do some additional digging to try to really figure out what’s causing the problem.

    While I still haven’t narrowed down exactly what’s causing this, I have come up with something that works for me.

    Basically, despite the fact that we have Domain Mapping set to redirect admin pages back to the original domain, all these links to Edit Page / Edit Post, etc, were using the mapped domain instead of the original domain. I added this small bit of code to mu-plugins, and now everything seems to be working for mapped sites (but not yet perfected for un-mapped sites. that’s next…).

    if ( !is_admin() ) { // infinite redirect loops without this
    	add_filter( 'admin_url', 'domain_mapping_use_original_url_for_frontend_links', 10, 3 );
    }
    
    function domain_mapping_use_original_url_for_frontend_links($url, $scheme ) {
    
    	return get_original_url() . '/wp-admin/' . $scheme;
    }

    If you have a moment, I’d love to hear your thoughts on this situation. Thanks!

    For reference, here’s my finished code that works for both mapped and un-mapped sites. It replaces links to mapped.com/wp-admin/etc with unmapped.com/map-slug/wp-admin/etc

    add_filter( 'admin_url', 'domain_mapping_use_original_url_for_frontend_links', 99, 3 );
    
    function domain_mapping_use_original_url_for_frontend_links($url, $scheme, $blog_id ) {
    
    	$o_url = get_original_url();
    
    	if ($o_url) {
    		// domain_mapped_site
    		return $o_url . '/wp-admin/' . $scheme;
    	} 
    
    	return $url;
    }
Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Links from Frontend to Backend always end at dashboard’ is closed to new replies.