Force users to login from main/dashboard blog by hiding all blogs login URL.

I'm using URL Group, I've used example.com/.+/wp-login.php to hide all login URLs(except for the main blog), I want to force all users to login to Main Blog then they can go to their blog if they want to. However, any URL contains wp-login.php wont work, it seems hard-coded. Any idea?

Thanks,

  • Vaughan

    Hi @man,

    You can try adding the following to a mu-plugin function.

    create a file called functions.php

    Add the following to it:

    <?php
    function wpmu_login_main($login_url, $redirect) {
            $new_login_url = network_site_url() . 'wp-login.php/?redirect_to=' . $redirect;
            return $new_login_url;
    }
    add_filter( 'login_url', 'wpmu_login_main', 10, 2 );

    Then upload it to wp-content/mu-plugins using FTP.

    If mu-plugins doesn't exist, create it.

    I haven't tested this, but hopefully it should work.

    Hope this helps

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.