BuddyDev

Search

Central Login/Registration Help


  • Participant
    Level: Enlightened
    Posts: 97
    Erich199 on #25227

    Hey Brajesh!
    Hope you’re doing well.

    I wanted to get some advise/help on a specific issue I’m dealing with.

    I’ve created a network of sites that share the user and user_meta tables but are separate installs. I’ve set up a common session cookie so that the sites have a single sign on environment. What I am stuck on is how to redirect all login/registration request to a specific domain and have them redirected back to the domain where they came from.

    Example:
    If a user logs in from Site B – they are taken to the login.mydomain.com subdomain. They sign in – when they are authenticated they are then returned back to Site B.

    Same for Registrations

    Is there some code I can use in the functions.php file for the login.mydomain.com or subdomain.mydomain.com to get this to work properly?

    Thanks for your help.

    PS – I am willing to pay for this one.


  • Keymaster
    (BuddyDev Team)
    Posts: 12238
    Brajesh Singh on #25232

    Hi Joshua,
    Welcome back.

    For login, It should be fairly easy to do with some custom code.

    For registration, I am not sure how your current registration works. Do you need activation for the accounts? We will need to find some way to validate the referrer(is from your network of sites) and store it to redirect later.

    I will post the code when I am back to work today.

    Thank you
    Brajesh


  • Participant
    Level: Enlightened
    Posts: 97
    Erich199 on #25264

    Hey Brajesh,
    I thought I did a follow up post about this but I don’t see it. Thanks again for all you do. If you have any specific questions please let me know.


  • Participant
    Level: Enlightened
    Posts: 97
    Erich199 on #25275
    This reply has been marked as private.

  • Keymaster
    (BuddyDev Team)
    Posts: 12238
    Brajesh Singh on #25286

    Hi,
    You may want to put a code like this in a plugin and network activate

    
    
    add_filter( 'login_url', function ( $login_url, $redirect, $force_reauth ) {
    	$login_url = 'https://login.tidesofwar.net';
    
    	$redirect = site_url( $_SERVER['REQUEST_URI'] );
    
    	$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;
    }, 3 );
    

    I haven’t tested it but this or slightly modified version of it should work for login.

    Please let me know how it goes.

    Regards
    Brajesh


  • Participant
    Level: Enlightened
    Posts: 97
    Erich199 on #25288

    Hi Brajesh,
    Thanks again for your help.

    This code seems to just cause the site to hang up. I put it in the functions.php file then refreshed the site and it just wouldn’t load.


  • Keymaster
    (BuddyDev Team)
    Posts: 12238
    Brajesh Singh on #25293

    Hi Joshua,
    Please make sure you have not copied for the notification mail and have copied it form the above reply.

    The code in notification mail gets entity encoded and will cause issue.

    Also, if you copy from above and it is still causing issue, Please check error log and post me.

    Thank you
    Brajesh


  • Participant
    Level: Enlightened
    Posts: 97
    Erich199 on #25295
    This reply has been marked as private.

  • Participant
    Level: Enlightened
    Posts: 97
    Erich199 on #25296
    This reply has been marked as private.

  • Keymaster
    (BuddyDev Team)
    Posts: 12238
    Brajesh Singh on #25300
    This reply has been marked as private.

You must be logged in to reply to this topic.

This topic is: not resolved
Subscribe