I want my members i.e admin of sub-sites to Login to their

Hi,
I want my members i.e admin of sub-sites to Login to their dashboard "ONLY" through my main website Login page. I wanted to block them using site1.maindomain.com/wp-login.php.
And When they Login from my site they should be directly taken to their dashboard,instead of seeing the screen that I attached,please help me.

  • Michael Bissett
    • Recruit

    Hey @Aatithyan, hope you're doing well today. :slight_smile:

    I want my members i.e admin of sub-sites to Login to their dashboard "ONLY" through my main website Login page.

    ...

    And When they Login from my site they should be directly taken to their dashboard,instead of seeing the screen that I attached,please help me.

    It looks like the plugin I've attached here would do that for you, could you give it a try?

    I wanted to block them using site1.maindomain.com/wp-login.php.

    Are you using anything to block them from accessing that sort of page at present, or is that something that still needs to be set up?

    Please advise,
    Michael

  • Michael Bissett
    • Recruit

    Hey @Aatithyan,

    It sounds like I'm going to have to have a closer look at your setup, could you send in the following:

    - Network admin details
    - The admin details for the sub site you're testing with
    - and, a link to this thread

    to contact(at)wpmudev.org, with the subject line Attn: Michael Bissett?

    Thanks!

    Regards,
    Michael

  • Ash
    • WordPress Hacker

    Hi @Aatithyan

    I hope you are well today.

    Your login information it not working anymore. Would you please try the following code:

    function go_to_primary_blog($redirect_to, $request, $user){
    	$user_info = get_userdata($user->ID);
    	return get_blogaddress_by_id($user_info->primary_blog) . 'wp-admin';
    }
    add_filter("login_redirect", "go_to_primary_blog", 10, 3);

    To add this code mu-plugins is the best solution. To use mu-plugins, go to /wp-content/ and find the folder with name 'mu-plugins'. If there is no folder in that name, then create a folder, name it 'mu-plugins', create a file inside that, give any name you like (e.g. login-redirect.php) and paste the code in there. You don't need to activate that plugin. Mu-plugins means must use plugins, so it will be activated automatically always. If you use mu-plugins then add a php start tag (<?php) at the beginning of the code.

    Hope it helps :slight_smile: Please feel free to ask more question if you have.

    Cheers
    Ash

  • Michael Bissett
    • Recruit

    Hey @Aatithyan,

    I've sent the login details you posted to @Ashok, but it sounds like we may have to look at the network dashboard again.

    Could you send in:

    - The new network admin details
    - FTP access details (just in case we need to look even deeper)
    - and, a link to this thread

    to contact(at)wpmudev.org (with the subject line Attn: Michael Bissett)?

    Thanks!

    Regards,
    Michael

  • Michael Bissett
    • Recruit

    Hey @Aatithyan,

    I have never used an FTP client before. I had created an new account in the cpanel. Now what details do you need? I mean only user name and password is enough or anything else do you need?

    Do you mean you created a new sub-site inside your Multisite network? Or do you mean you created a new account inside the control panel for your web hosting?

    In regards to the FTP details, here's the article that your web host has on where you can find that information:

    http://support.hostgator.com/articles/ftp/ftp-settings-and-connection

    Like I said earlier, I'll need:

    - The new network admin details for your Multisite network
    - FTP access details (just in case we need to look even deeper)
    - and, a link to this thread

    If you could send that to contact(at)wpmudev.org (with the subject line Attn: Michael Bissett), that'd be great. :slight_smile:

    Thanks!

    Regards,
    Michael

  • Aatithyan
    • Design Lord, Child of Thor

    Hi @Michael

    I just resolved this issue by following an forum in wordpress.org. The code below will redirect sub-sites admin users to reach their dashboard from main sites Login page.

    <?php
    function ds_login_redirect( $redirect_to, $request_redirect_to, $user )
    {
        if ($user->ID != 0) {
            $user_info = get_userdata($user->ID);
            if ($user_info->primary_blog) {
                $primary_url = get_blogaddress_by_id($user_info->primary_blog) . 'wp-admin/';
                if ($primary_url) {
                    wp_redirect($primary_url);
                    die();
                }
            }
        }
        return $redirect_to;
    }
    add_filter('login_redirect','ds_login_redirect', 100, 3);
    ?>

    The above code should be placed in mu-plugins.

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.