• Resolved giovancruz

    (@giovancruz)


    Hi, thanks for this plugin.

    We’re using this on a multisite env and it works nice, but we’ve found that the URLs for the other sites dashboard on the frontend links to the incorrect wp-admin on the wp-admin-bar-my-sites for network sites and on my-sites.php.

    If you’re logged in and try to switch from one site to the other one it leads to 404.

    I tried to find the hook for changing these urls but I couldn’t find yet, I’ll return here with the solution if I find.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter giovancruz

    (@giovancruz)

    It’s more complex than it seems, I managed to create a php script to alter these urls however the problem is that if you’re already logged in to the target multisite, trying to send to the custom link will return 404. When you’re not logged in, it should send to the custom url and if not, it should link to the custom URL. Tricky.

    <?php

    if ( ! defined('CUSTOM_ADMIN_SLUG') ) {
    define('CUSTOM_ADMIN_SLUG', 'dashboard-login/');
    }

    /**
    * Build the custom admin base for a given site.
    */
    function gi_custom_admin_base($blog_id = null) {
    $site_url = $blog_id ? get_site_url($blog_id, '/') : site_url('/');
    return trailingslashit($site_url) . trailingslashit(untrailingslashit(CUSTOM_ADMIN_SLUG));
    }

    /**
    * Core filter to rewrite admin URLs.
    */
    function gi_filter_admin_url($url, $path, $blog_id) {
    if (gi_skip_admin_rewrite((string)$path)) {
    return $url; // leave core endpoints intact
    }

    $from = '/wp-admin/';
    $to = '/' . trailingslashit(untrailingslashit(CUSTOM_ADMIN_SLUG));

    if (! empty($path)) {
    $url = gi_custom_admin_base($blog_id) . ltrim($path, '/');
    } else {
    $url = str_replace($from, $to, $url);
    if (strpos($url, $to) === false) {
    $url = gi_custom_admin_base($blog_id);
    }
    }

    return $url;
    }
    add_filter('admin_url', 'gi_filter_admin_url', 99, 3);
    Plugin Support Lea WPServeur

    (@leacomm)

    Hi,
    Thanks for using WPS Hide Login.
    Our plugin is only used to customize the login URL.
    It doesn’t change the WordPress admin URL.
    Regards.

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Multisite env urls for dashboard’ is closed to new replies.