Problem with user login on my original domain

Hello,

When users have created their own site, they have to go to their site to login (examble.forenigo.dk/wp-login.php)

It thought that when a user pressed login on the original domain forenigo.dk, they should be redirected to their own page. They don't. When they do that, they only get to change their user information and stay on my url.

Are these settings set correct?

Hope you understand my problem. :slight_smile:
(When you press login on my page, you get this url (https://forenigo.dk/wp-login.php. I would then asume, that if a user logged in, he would automaticly be redirected to his own site as an admin.)

Best regards
Nicolaj

  • James Morris
    • WordPress Enthusiast

    Hello Nicolaj,

    I hope you are well today.

    You currently have Domain Mapping set to go to "Original domain". This will automatically map logins and redirection back to the Network Admin domain (forenigo.dk/wp-admin/).

    To force login on the subsite, you need to change this setting to "Mapped Domain" or "Domain entered by user". This will allow for login at examble.forenigo.dk/wp-login.php

    I hope this clarifies a bit.

    Best regards,

    James Morris

  • Luís
    • Support

    Hi Nicolaj ,

    Hope you're doing well today!

    Working here alongside with my teammate James.

    If I understood well, you want the users be redirected to their subsites after make the login in the main site (forenigo.dk), right?

    Domain Mapping doens't have any option to do this, it will require some custom code. One of our members shared a snippet that I think it may interest you:

    https://premium.wpmudev.org/forums/topic/redirect-user-to-their-primary-site-dashboard-after-login-on-the-main-site#post-1197453

    Attached I send the mu-plugin I used in my tests, if you are interest:

    1) Download the .zip file attached and unzip it;

    2) Using FTP access, upload "redirect_after_login.php" to "/wp-content/mu-plugins" folder;

    Note: If you don't have a "mu-plugins" folder inside "wp-content", please, create it.

    I hope this information has been helpful. If I can help you in this or other questions, please let me know!

    Cheers, Luís

  • Nicolaj
    • Design Lord, Child of Thor

    Hello guys,

    I'm sorry but I have 2 problems with this:
    1. If i'm a user and log in to the main site, it redirects me fine, but only to the login page on the mapped domain. So I have to type in my info again.
    2. When I log out from the user site and go back to the main site, I'm logged in here. How can I restrict acces? So the user only can log in to his own site.

    I have just recorded the two problems, so you can understand what I'm saying in case I can't explain it well :slight_smile: Watch here: https://youtu.be/yZ9GKBlNRnc

    And thank you for your time :slight_smile:

    Best regards
    Nicolaj

  • Luís
    • Support

    Hi Nicolaj ,

    Hope you're doing well today!

    My first thought was that could be related to the "Cross-domain autologin" be set to "No", but I did some tests in my install and was unable to replicate both of your issues.

    Can you please send us the FTP details of your website so we can investigate this issue further? If yes, please send it privately through our contact form:

    https://premium.wpmudev.org/contact/#i-have-a-different-question

    Send in:
    Subject: "Attn: Luis Lopes"
    - WordPress admin username
    - WordPress admin password
    - Login url
    - FTP credentials (host/username/password)
    - Link back to this thread for reference
    - Any other relevant urls/information

    Cheers, Luís

    • Nicolaj
      • Design Lord, Child of Thor

      Hello Luís,

      Have you looked at my site? I noticed that you've created an account :slight_smile: I will just let you know, that it seems the front-end editor option is gone when you login again after redirected. You simple doesn't have the option to customize.

      Hope you are well,

      - Nicolaj

  • Ivan
    • Developer

    Hi Nicolaj !

    I disabled "redirect_after_login.php" MU plugin and checked with "wpmu" user. I see on Users page for your network that he has access only for "code" site. After login to your main site I see this

    He hasn't an access to Admin area of the main site.
    After hitting on Dashboard link you can see this message of your browser

    If you ignore this message (hit on a link " Proceed to code.*** (unsafe) ":wink: - it will open wp-admin for "code" site without re-input your credentials. After resolving issue about "https" for your subdomains it will work as you want.

    Please, let me know if I missed something.

    Best regards,
    Ivan.

  • Nicolaj
    • Design Lord, Child of Thor

    Hello Ivan,
    Thank you for your time, but it does not work that way. I'm still send to the back-end of the main domain, when logging in as a costumer. BUT Ivan, I decided to remove the "log in" tab on my website and only referring costumers to log in with their link in their email. My main problem is when a customer is logged in to the main site and then go to his own domain and log in, he can't access the front-end/visual editor! When he goes back to the main site, log out, then goes back to his own, log out and then log in again, the editor option is back!

    SO NOW ! :smiley: The biggest problem is when a user just created an account and a site, they are automatically logged in to the main site. Then the customer checks his email and presses the link to his own site, the editor does not work!.

    - So if you just could fix either the editor not working when logged into 2 sites, or do so the customer is NOT logged in the main site, during creation of a site, I would be happy!

    This should be easier, because I have had a lot of problems fixing the redirect. So please help me with one of the two options as just described :slight_smile:

    Have a nice day,
    Best regards
    Nicolaj

  • Ivan
    • Developer

    Hi Nicolaj !

    It seems I found a solution for you. I created MU plugin on your site (wordpress_folder)/wp-content/mu-plugins/wpmu_change_secure_logged_in_cookie.php via FTP with this code

    <?php
    
    function wpmu_change_secure_logged_in_cookie( $secure_logged_in_cookie, $user_id, $secure ) {
        return false;
    }
    add_filter( 'secure_logged_in_cookie' , 'wpmu_change_secure_logged_in_cookie' , 10, 3);

    Also, you can use this solution for changing links for subsites from https:// to http://.

    Please, let me know how it goes for you.

    Best regards,
    Ivan.

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.