Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I have a multisite, where I would like any subsites to share the same login, register and lost password page. Those pages are custom pages and located on the main site. So far so good. The problem I have now, is that when a user want to submit contents to any of the subsites it should be directed to the common login page then after login send back to the form submission page. I have tried following codes which did not provide the desired result: It sends the user to the login page, but is missing the url to get back to

    add_action('init','possibly_redirect');
function possibly_redirect(){
    global $pagenow;
    if( 'wp-login.php' == $pagenow ) {
    wp_redirect( network_site_url( 'login' ) );
    exit();
    }
}

Then I found this code, but it does not alter the login url:

add_filter( 'login_url', 'mysite_login_url', 10, 2);
function mysite_login_url( $force_reauth, $redirect ){
    $login_url = 'yoursite_login_url';

    if ( !empty($redirect) )
        $login_url = add_query_arg( 'redirect_to', urlencode( $redirect ), $login_url );

    if ( $force_reauth )
        $login_url = add_query_arg( 'reauth', '1', $login_url ) ;

    return $login_url ;
}

Is there a way I can combine or use side by side to reach a solution. Being a newbie, I have tried every combination I came accross. I also tried rewriting rule in .htaccess, but it did not work. Thanks

share|improve this question
    
I don't use multisite but I was under the impression that it already redirected to a centralized login page. Is that not correct? –  s_ha_dum Jul 21 '13 at 15:00
    
@s_ha_dum, yes it does redirect, but to subsite wp-login.php. Here´s the scenario I would like to achieve: mysite.com/site1/form-page/ has a form. Not logged in user will be send to mysite.com/login. After success they will be send back to mysite.com/site1/form-page/ to perform the form submission. –  Totem Jul 21 '13 at 19:51

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.