We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 4273
    • 356 Posts
    where in the websignup form is the require field code and if we want to add more fields to the sign up form and make some required what would we need to add ?
      SMF Bookmark Mod - check it out
      http://mods.simplemachines.org/index.php?mod=350
      • 33453
      • 141 Posts
      You will find it in assets/snippets/weblogin/websignup.inc.php.

      I suggest you make a copy before hacking.
        • 4273
        • 356 Posts
        I see the page but don’t see the required field code, what to add if we want to include additional fields ?
          SMF Bookmark Mod - check it out
          http://mods.simplemachines.org/index.php?mod=350
          • 8471
          • 333 Posts
          I’m also interested in required fields, how can we add a required field ?
            Sorry for my bad English grin
            • 23363
            • 43 Posts
            Maybe a late reply, but hopefully helpful.

            At line 49 of snippets/weblogin/websignup.inc.php you’ll find
                if($username=="") {
                    $output = webLoginAlert("Missing username. Please enter a user name.").$tpl;
                    return;
                }
            


            This piece of code you can copy and modify for each extra requirered field.
                if($fullname=="") {
                    $output = webLoginAlert("Missing Fullname. Your fullname is a required field.").$tpl;
                    return;
                }
            


            Do make shure you don’t paste the code in between an other if/else statement/


            If you have a lot of required fields is nicer to save all the error messages and out put them all at once (including the existing error messages)
            $error = '';
                if($firstname=="") {
                    $error .= "forgot your firstname \n";
                }
                if($lastname=="") {
                    $error .= "forgot your lastname \n";
                }
                if($zipcode=="") {
                    $error .= "forgot your zipcode \n";
                }
            if($error > ''){
                    $output = webLoginAlert($error).$tpl;
                    return;
            }
            


            Don’t forget to make a backup form the original document and one of your modifications when you do a update op Modx

              • 4310
              • 2,310 Posts
              Here are a couple more ideas, including basic validation :
              // check for missing surname
              	if($surname=="") {
              		$output = webLoginAlert(WL_MISSINGSURNAME).$tpl;
              		return;
              	}
              	// verify surname
              	$regex="[A-Za-z[:blank:]-]{2}";
              	if(!ereg($regex, $surname)){
              		$output = webLoginAlert(WL_SURNAMENOTVALID).$tpl;
              		return;
              	}
              // check for missing telephone
              	if($telephone==''){
              		$output = webLoginAlert(WL_MISSINGTEL).$tpl;
              		return;
              	}
              	// verify telephone
              	$regex="[0-9 ()+-]{10}";
              	if(!ereg($regex, $telephone)){
              		$output = webLoginAlert(WL_TELNOTVALID).$tpl;
              		return;
              	}
                • 25519
                • 265 Posts
                Hi
                Where you have the following:
                $output = webLoginAlert(WL_SURNAMENOTVALID).$tpl;

                Is (WL_SURNAMENOTVALID) an inbuilt/generic modx chunk, or is it one I would write myself for the alert?
                  • 4310
                  • 2,310 Posts
                  Sorry, in assets/snippets/weblogin/langauge/yourlanguage.php you need to add an extrat line :
                  define("WL_SURNAMENOTVALID","Surname doesn't seem to be valid, only letters spaces and hyphens allowed.");