We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 30025
    • 32 Posts
    I am creating an Ajax login form using jquery. What I need is for the Login snippet to return a message of OK if login was a success. If there are errors logging in I need Login snippet to return the errors. I searched all through the snippet as well as the files in core/components/login and could not figure it out. Can anyone help me or point me in the right direction?
      • 1778
      • 659 Posts
      Hello

      I guess you can use custom hooks to perform that. You should have a look at http://rtfm.modx.com/display/ADDON/Login.Using+Pre+and+Post+Hooks, and look deeper at this part "Custom hook return values" and the examples given...

      Hope this is of use to you...
      Cheers
        • 30025
        • 32 Posts
        Thanks for the response Anso but I am still at a loss for what to do. The Login snippet is pretty complex. I have a login form that works fine with the snippet. However I want to turn it into an ajax form. To do this I need something along the lines of the following for login snippet.

        If login successful then return "OK"
        If login failed then return "Error:"

        This way I can take what the snippet returns in my Ajax call and say something like

        If msg = "OK" then .... refresh page
        If msg != "OK" then display msg

        The only problem I am having right now is that it seems that the Login snippet returns the link to a webpage. I want to be able to return what I want but I cannot figure it out because of the complexity of the Login snippet. Can someone point me in the right direction or give me an example? I have read the Login documentation in the WIKI and still cannot figure out what I need to do.