single register/login for multisite

I am hoping someone can shed some light on this issue regarding login for multisite.
I am using the plugin Wordpress Social Login on my main site but am noticing this issue.
If a user is on a subsite and tries to login instead of going to http://www.myMainSite/wp-login.php they instead go to http://www.myMainSite/subsite/wp-login.php
The problem with this is that with the social login the API's for the social logins such as google+ do not match the URL for the subsite.
Is there a way to have all logins redirect to http://www.myMainSite/wp-login.php

Thank you for your help

  • smithmeriam

    Hi Patrick,
    Yes the one you suggested does look nice however it looks like only the social sharing function is free, the login portion has a monthly charge that is out of my range.
    What I was hoping was if there was a way to have the wp-login always use the main site login. I do not want users to login to the subsites (in fact I do not allow subsites to add users apart from the admin who created the site), I already have users who are subsite admins being redirect to their home subsite.
    Is there some way that when a user clicks the login link they are always redirected to the main sites wp-login.php no matter what subsite they are browsing on. By the way I'm using the wp_loginout() function. I know that tampering with the wp files isnt a good idea but is there a way to insure that this function goes to the main site login always? I'm thinking some sort of filter in my theme functions file. I'm snooping around on the web to see if there is anything that shows up
    I would like my login to be more Etsy like in that even if you are on a shop page when you login or register it is with Etsy not with the sub-shop.

    Thank you again

  • smithmeriam

    I found this bit for changing the text, is it possible to change the url instead

    function loginout_text_change($text) {
        $login_text_before = 'Log in';
        $login_text_after = 'Sign-In';
        $logout_text_before = 'Log';
        $logout_text_after = 'Logout';
        $text = str_replace($login_text_before, $login_text_after ,$text);
        $text = str_replace($logout_text_before, $logout_text_after ,$text);
        return $text;
  • smithmeriam

    So I have added this to my theme functions file and it seems to be working. Hopefully it shouldnt create any problems (I am a bit leary of hardcoding my site url, is there a better way?

    function loginout_link_change($link) {
        $login_link_before = '<a href="' . esc_url( wp_login_url($redirect) ) . '">' . __('Log in') . '</a>';
        $login_link_after = '<a href="">' . __('Log in') . '</a>';
        $link = str_replace($login_link_before, $login_link_after ,$link);
        return $link;
  • Sumit Kumar

    Hi @Meriam,
    Hope you are doing good today :slight_smile:

    Its really appreciated with your attempt to see that you been able to create your own code snippet to solve the issue for you :slight_smile:. It just works perfect, as you said and of course there won't be issue as I see.

    However, I just wanna modify your code with two small points there.
    -> Modify your static link there "" to dynamic.
    -> Add redirect link to login url so that user will return back to subsite after login.
    Here's that updated code for you:

    function loginout_link_change($link) {
        $login_link_before = '<a href="' . esc_url( wp_login_url($redirect) ) . '">' . __('Log in') . '</a>';
        $login_link_after = '<a href="'.network_site_url().'wp-login.php/?redirect_to='. esc_url($_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"]).'">' . __('Log in') . '</a>';
        $link = str_replace($login_link_before, $login_link_after ,$link);
        return $link;

    I hope this will be helpful for you!
    Have a great day. :slight_smile:

    Warm Regards,

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.