WordPress.org

Ready to get started?Download WordPress

Forums

Login message (3 posts)

  1. micam1
    Member
    Posted 4 months ago #

    Is there a way to allow a user to login to their site from your main site login screen.

    I am designing a sub domain multisite and if I register a user + site and log that user in on mysite.com/wp-login.php It doesn't redirect to the user site and get the following message:

    You attempted to access the "my site" dashboard, but you do not currently have privileges on this site. If you believe you should be able to access the "my site" dashboard, please contact your network administrator.

    If you reached this screen by accident and meant to visit one of your own sites, here are some shortcuts to help you find your way.

    It then has links below the messsage to visit the user site and dashboard.

    The user can log in straight away if the user logs in to the direct url to the site; usersite.mysite.com/wp-admin.php

    This also seems to just be a sub-domain setup problem. If I create a sub-directory multisite install and register a new user + site, they can login on my main website; mywebsite.com/wp-login.php and it directs them straight to their admin; mywebsite.com/usersite/wp-admin.php.

    Is this is what supposed to happen on sub-domain setup? If so, is there anyway to do a redirect so when they login they go straight to their site? there is this one:

    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);

    but you have to login twice with this code, once for the redirect to the users site url login page and then again to log in.

    Any help with this will be much appreciated.

  2. Yes, this is what's supposed to happen. While the account is on the network, the access is per SITE, so if you log in on Site #1 and you don't have access....

    but you have to login twice with this code, once for the redirect to the users site url login page and then again to log in.

    Yeah, that's because it's Subdomains. While the user IS logged in, Browsers don't share cookies between subdomains. Can't. Security things :/

  3. micam1
    Member
    Posted 4 months ago #

    Thanks for the reply Ipstenu.

    I think I may be tempted to go back to a sub-directory multisite because this could become annoying or confusing for users, I only recently changed because I prefer the url structure for sub-domains, also I couldn't find a way of having https on my homepage only and http on user blogs.

    Is there definitely no way of doing this, such as any type of plugin that allows a global login? There seems to be no solution for this but I'm just wondering how wordpress.com works as you are able to login at wordpress.com/login

    Alternatively, if I decide to go back and use sub-directory multisite is there a way to have https on my homepage only? I have this in htaccess:

    RewriteCond %{HTTP_HOST} ^mysite\.com
    RewriteCond %{SERVER_PORT} !443
    RewriteRule ^(.*)$ https://mysite.com/$1 [R,L]

    This works great for sub-domains but anything similar to this will make my whole site use https for a sub-directory multisite.

Reply

You must log in to post.

About this Topic

Tags

No tags yet.