Sub Site logins and Registrations doing strange things

When I try and register a new account from a subdomain site.. ex.
https://adeon.lightworkers.org/
It takes me to https://lightworkers.org/pro-site/?action=new_blog
--
Process should be.. User registers and is taken back to the subsite they registered through.
So I should end up back at :
https://adeon.lightworkers.org/
Right?

Also if I try and Login to
https://adeon.lightworkers.org/ using the Login Option in the site meta.
It brings up the login form.. I enter details.. then it takes me to the main site lightworkers.org
(And shows me as Not logged in)
If I then return to https://adeon.lightworkers.org/ I will be logged in.

Shouldn't I be able to just login to the network through https://adeon.lightworkers.org/

Am I missing something here?

Thanks

Adeon

  • Sajid

    Hi Adeon,
    Hope you are doing good today!

    For user registration, every user must be redirected to main site and specially to checkout page if you have enabled signup on checkout option of Pro Sites. So that behaviour is correct.

    For login redirect to subdomain after login, try adding following code in functions.php file of your child theme or use it as mu-plugin.

    function login_site_redirect ( $redirect_to ) {
    	global $user;
    	$primary_blog_id = get_usermeta($user->ID, 'primary_blog');
    	$blog_details = get_blog_details($primary_blog_id);
    	$redirect_url = $blog_details->siteurl;
    	return $redirect_url;
    }
    
    add_filter ( 'login_redirect', 'login_site_redirect', 10, 3 ) ;

    If you take the mu-plugin route, you'll want to log into your site via FTP, and go to your /wp-content/ folder via FTP, finding the folder called "mu-plugins".

    If there's no folder with that name, then you'll want to create one. Then, create a file inside that folder, and give the file any name you like (making sure the file has an extension of .php, e.g. example.php) and paste the code in there.

    It'll always be active, so there's no need to activate the plugin after creation. Be sure to add a PHP start tag at the beginning of the code, like this:

    <?php

    For not login issue on main or other site, try using the following plugin for Single Sign On (SSO) across the network.
    https://wordpress.org/plugins/wp-multisite-sso/

    If you are using our Domain Mapping plugin then you don't need to use above plugin because it has built in option of SSO.

    Hope that helps! Feel free to post a reply if you need further assistance :slight_smile:

    Best Regards,
    Sajid