We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 40122
    • 330 Posts
    I am using the Login plugin and have 2 login forms that log the user into a different user group depending on which one they submit.

    However, it does not seem they want to cooperate, being on the same page.

    My code is as such:

    <div id="seekersloginslider" class="ctaslider">
        <h2>Job Seekers Login</h2>
        [[!Login? &loginResourceId=`32`]]
    </div>
    
    <div id="employersloginslider" class="ctaslider">
        <h2>Employers Login</h2>
        [[!Login? &loginResourceId=`18`]]
    </div>


    No matter which form I use I will always be directed to Resource 32. If I try logging in with the lower 'Employers' form it will redirect to resource 32 and cause a 404.

    If I remove the upper, 'Job Seekers' form, the lower login form works as expected, redirecting me to Resource 18.

    Does anyone know a way to have both forms working on the same page?

    Thanks!
      • 42562
      • 1,145 Posts
      If you must carry on with your method of having multiple Logins, try...
      <div id="seekersloginslider" class="ctaslider">
          <h2>Job Seekers Login</h2>
          [[!Login? &loginResourceId=`32` &loginTpl=`lgnLoginTpl-1`]]
      </div>
       
      <div id="employersloginslider" class="ctaslider">
          <h2>Employers Login</h2>
          [[!Login? &loginResourceId=`18` &loginTpl=`lgnLoginTpl-2`]]
      </div>


      In chunk lgnLoginTpl-2, find
      <input class="returnUrl" type="hidden" name="returnUrl" value="[[+request_uri]]" />
      and manually insert request_uri
      <input class="returnUrl" type="hidden" name="returnUrl" value="myredirect2.html" /> 
        TinymceWrapper: Complete back/frontend content solution.
        Harden your MODX site by passwording your three main folders: core, manager, connectors and renaming your assets (thank me later!)
        5 ways to sniff / hack your own sites; even with renamed/hidden folders, burst them all up, to see how secure you are not.
        • 44580
        • 189 Posts
        I assume you are differentiating Employers and Seekers by making them members of different groups. If so, you could use the redirectUsergroups extra and have a single login form. Much cleaner IMO.
          • 40122
          • 330 Posts
          Quote from: donshakespeare at Jan 12, 2015, 08:50 AM
          If you must carry on with your method of having multiple Logins, try...
          <div id="seekersloginslider" class="ctaslider">
              <h2>Job Seekers Login</h2>
              [[!Login? &loginResourceId=`32` &loginTpl=`lgnLoginTpl-1`]]
          </div>
           
          <div id="employersloginslider" class="ctaslider">
              <h2>Employers Login</h2>
              [[!Login? &loginResourceId=`18` &loginTpl=`lgnLoginTpl-2`]]
          </div>


          In chunk lgnLoginTpl-2, find
          <input class="returnUrl" type="hidden" name="returnUrl" value="[[+request_uri]]">
          and manually insert request_uri
          <input class="returnUrl" type="hidden" name="returnUrl" value="myredirect2.html"> 

          Thanks but no luck there - behaves the same
            • 42562
            • 1,145 Posts
            Both lgnLoginTpl1 and 2 have different value="myredirect2.html" and it is still misbehaving?
            Weird! Above is exactly how I solved it for myself.
              TinymceWrapper: Complete back/frontend content solution.
              Harden your MODX site by passwording your three main folders: core, manager, connectors and renaming your assets (thank me later!)
              5 ways to sniff / hack your own sites; even with renamed/hidden folders, burst them all up, to see how secure you are not.
              • 46886
              • 1,154 Posts
              Let's have the tpl files to look at, can we?

              I think the issue could be the multiple loginResourceID values, these are just telling the system where the login resource is, is there a need to have two different resources? If the two redirects are there it should be enough.
                • 40122
                • 330 Posts
                Quote from: nuan88 at Jan 13, 2015, 04:30 AM
                Let's have the tpl files to look at, can we?

                My modified lgnLoginTpl-2 is as follows:



                <div class="loginForm">
                    <div class="loginMessage">[[+errors]]</div>
                    <div class="loginLogin">
                        <form class="loginLoginForm" action="[[~[[*id]]]]" method="post">
                            <fieldset class="loginLoginFieldset">
                                <legend class="loginLegend">[[+actionMsg]]</legend>
                                <label class="loginUsernameLabel">[[%login.username]]
                                    <input class="loginUsername" type="text" name="username" />
                                </label>
                                
                                <label class="loginPasswordLabel">[[%login.password]]
                                    <input class="loginPassword" type="password" name="password" />
                                </label>
                                <input class="returnUrl" type="hidden" name="returnUrl" value="http://mysite.com/index.php?id=18" />
                
                                [[+login.recaptcha_html]]
                                
                                <input class="loginLoginValue" type="hidden" name="service" value="login" />
                                <span class="loginLoginButton"><input type="submit" name="Login" value="[[+actionMsg]]" /></span>
                            </fieldset>
                        </form>
                    </div>
                </div>


                I have also tried:

                <input class="returnUrl" type="hidden" name="returnUrl" value="[[~18]]" />


                Thanks!
                  • 46886
                  • 1,154 Posts
                  Ok thanks meltingdog, but could we also see the first template and the login resource contents?

                  I think the login resource itself could be causing this trouble, again I am suspicious of the two login resources. But its important to see the returnurl in the first template.

                  So it always redirects to the first login resource, right? That's why I want to see the redirect of template 1. After we look at all of it, you could try changing the redirect of template 1 to see if its even getting to that point. I suspect it is not.
                    • 40122
                    • 330 Posts
                    Quote from: nuan88 at Jan 13, 2015, 08:08 PM
                    Ok thanks meltingdog, but could we also see the first template and the login resource contents?


                    The first template is as is, unaltered:

                    <div class="loginForm">
                        <div class="loginMessage">[[+errors]]</div>
                        <div class="loginLogin">
                            <form class="loginLoginForm" action="[[~[[*id]]]]" method="post">
                                <fieldset class="loginLoginFieldset">
                                    <legend class="loginLegend">[[+actionMsg]]</legend>
                                    <label class="loginUsernameLabel">[[%login.username]]
                                        <input class="loginUsername" type="text" name="username" />
                                    </label>
                                    
                                    <label class="loginPasswordLabel">[[%login.password]]
                                        <input class="loginPassword" type="password" name="password" />
                                    </label>
                                    <input class="returnUrl" type="hidden" name="returnUrl" value="[[+request_uri]]" />
                    
                                    [[+login.recaptcha_html]]
                                    
                                    <input class="loginLoginValue" type="hidden" name="service" value="login" />
                                    <span class="loginLoginButton"><input type="submit" name="Login" value="[[+actionMsg]]" /></span>
                                </fieldset>
                            </form>
                        </div>
                    </div>


                    The login form for lgnLoginTpl-2 is:

                    [[!Login? &loginResourceId=`18` &loginTpl=`lgnLoginTpl-2`]]
                      • 46886
                      • 1,154 Posts
                      Ok I am not an expert, and someone more capable than me will probably jump in. But I think I can make some points that could help.

                      For these lines in both login calls: [[!Login? &loginResourceId=`32` &loginTpl=`lgnLoginTpl-1`]]

                      The login resource ID is not the number of the resource in the tree, but rather the number of the snippet in Elements section.

                      In order for you to have both 32 and 18 as the number of the login snippet, you would have had to copy it and make a new one. Did you do that? Do you have two snippets, 18 and 32, with the same contents?

                      I suspect what is happening here is that snippet number 18 does not have the login contents, and therefore is getting skipped over, basically. But I could be way off base.

                      Could you confirm that you have the two identical snippets? Again, the number is the snippet number, not the resource number.