We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 19797
    • 18 Posts
    Is there any internal need for unique email addresses in modx?
      • 22303 MODX Staff
      • 10,725 Posts
      To uniquely identify people’s email address? rolleyes Maybe if you expand on the question a little, someone will have a better answer, cause I have no idea what you are asking...
        • 19797
        • 18 Posts
        OOTB, the websignup section of the weblogin snippet has a unique email constraint. Can I change this to suit my business needs or does modx require web users to have unique email addresses?

        for reference, from websignup.inc.php:
            // check for duplicate email address
            $sql = "SELECT internalKey FROM ".$modx->getFullTableName("web_user_attributes")." WHERE email='$email'";
            if(!$rs = $modx->db->query($sql)){
                $output = webLoginAlert("An error occured while attempting to retreive all users with email $email.").$tpl;
                return;
            } 
            $limit = $modx->db->getRecordCount($rs);
            if($limit>0) {
                $row=$modx->db->getRow($rs);
                if($row['internalKey']!=$id) {
                    $output = webLoginAlert("Email is already in use!").$tpl;
                    return;
                }
            }
        


        Thanks in advance!
        -Matt
          • 22303 MODX Staff
          • 10,725 Posts
          You can change it however you desire. There is no requirement for the MODx core engine to have users with unique email addresses. This is a typical scenario, and I’ve deployed a site or two with MODx that do allow multiple users with the same email address to signup.
            • 19797
            • 18 Posts
            Awesome sauce. Thanks a bunch!

            -Matt
              • 22303 MODX Staff
              • 10,725 Posts
              I do suggest however, that you make a copy of the snippet as well as the files in /assets/snippets/weblogin in another directory, so you can maintain your customizations without fear that future upgrades will overwrite your changes...
                • 19797
                • 18 Posts
                Yep, I actually considered using some sort of source control system, the most likely just being a folder with customized src in the same dir structure. Beyond Compare ftw! Until I get around to that, I’ve been creating .bak files before I modify.

                Thanks for the suggestion