• Hi,
    I want to create a user portal where users can use the main domain as their login page, when they enter their info and log in, they should redirect to their assigned dashboard (subdomain dashboard).
    Scenario:
    A user wants to login into their sub-domain dashboard, They go to the main website, click on login, go to the login page, and enter their info, once they click login, they should redirect to their dashboard which is the wp-admin of the sub-domain assigned to their account.

    Thanks.

    The page I need help with: [log in to see the link]

Viewing 1 replies (of 1 total)
  • Moderator bcworkz

    (@bcworkz)

    You can use wp_redirect() to take users where you like, provided no other output has yet started. The question is how we should determine which sub-domain belongs to the user. Every user has a “primary_site” meta value, revealing that user’s primary site ID. To get the URL belonging to that site ID, pass the ID to get_site_url()

    Untested, but I believe you could hook the “admin_init” action from which to redirect from. You’ll need some conditions to prevent infinite looping and other usability issues. If the current site is already the user’s primary, do not redirect. If there is no current user, presumably they want to log in and should not be redirected. There may be other conditions to check as well.

Viewing 1 replies (of 1 total)
  • The topic ‘User Management Portal’ is closed to new replies.