We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 39977
    • 11 Posts
    Hello,

    My apologizes if this question has an obvious answer.

    If you create a new registration with an already existing username, I have not received an error (natively) and end up being redirected to the pending reservation page, even though it does NOT create a second identical username in the database (user, user_attribute(profile). I looked up the controller code and there is an extensive validation for username, including if that name exists, and I see the in code failure listed (which is why it does not create the duplicate database entry).

    How to do catch that error to return an alternative message/redirect? Better yet, is there a validation phrase to add to the HTML, other than "required" or "minlength=x" that flags the user registering that this user name already is taken? (with a lexicon message) ... or do I have to create a custom validator to inform the user registering?

    Is there a larger list of approved login registration validators somewhere? I must be missing something obvious.

    I have an operating Plug-in for page redirection based on Log-in group. I have register prehooks to combine First and Last Name, and posthooks to update external databases with registration data, catch return keys, and place in extended fields, and assign member groups to this new user based on pull-down selection, all coded and working well (from the examples I have seen posted and Bob's wonderful book). I am just trying to control the user and control propagation of error conditions (username exists, email exists, companyname exists, etc).

    I have be searching for relevant posts. Any hints appreciated.
    Thanks as always,
    Paul

    Login 1.8.1
    Formit 2.1.2
    Modx Revo 2.2.5
    Xampp 1.8.1
    MySQL 5.5.27
    Appache 2.4.3
    PHP 5.4.7
      • 39977
      • 11 Posts
      Is there a login registration validation for "existing username"? If so, how do you call it?

      If not, how do you catch a failed new user registration create (because username or email exists) and so I can redirect to other than the pending request page and not appear to send the confirming email?

      Thx
        • 39977
        • 11 Posts
        $chkuser = new LoginRegisterController;
        return $chkuser->validateUsername()
          • 39977
          • 11 Posts
          $uname = $scriptProperties['value'];
          $alreadyExists = $this->modx->getObject('modUser',array('username' => $uname));
          If ($alreadyExists) return false;