We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 26310
    • 130 Posts
    Hi y’all,

    Ok so I have a user registration form using WebloginPE....

    If I wanted to split the fullname into a first and last name what does anyone recommend? Using javascript to take two form fields (first and last) and merge them into a hidden fullname field? Or maybe a snippet being called before the form is parsed? Is this something I’d use PHX for?

    The issue arises from JOT. I’m using the users email address as their username so I modified JOT to display the fullname field for comments. The only thing is I don’t really want to display the first and last name of a user. So maybe just split on the space in fullname on the JOT side???

    The latter solution would probably work but sometimes you get some different names out there and i’d hate to split a name in the wrong spot.

    Any suggestions? To me it’d be easier if I could just capture the first and last name at registration rather than tweak the fullname.
      I twitch because I care....and drink too much coffee.
      • 7155
      • 160 Posts
      Quote from: sbRyGuy at Jul 17, 2009, 05:07 PM

      To me it’d be easier if I could just capture the first and last name at registration rather than tweak the fullname.

      It can be done by making use of customfields. WebloginPE allows you to create fields as you would require them. You can the modify or create new templates for your own purposes.
      This is off my head, I havent tried it:

      • Look into the sub-folder Default Forms in your webloginpe folder.
      • Look for the file "defaultRegisterInstantFormTpl.html.txt",
      • Copy the contents and paste it in your editor program (e.g. Dreamweaver) as a new chunk named "defaultRegisterInstantFormTpl"

      • [li]Replace the following:
      
      			<label for="wlpeUserRegisterFullName"><span class="required">*</span> Full Name
      			<input id="wlpeUserRegisterFullName" type="text" name="fullname" value="[+post.fullname+]" />
      			</label>
      


      With:
      			<label for="wlpeUserRegisterFirstName"><span class="required">*</span> First Name
      			<input id="wlpeUserRegisterFirstName" type="text" name="firstname" value="[+post.firstname+]" />
      			</label>
      
      
      			<label for="wlpeUserRegisterLastName"><span class="required">*</span> Last Name
      			<input id="wlpeUserRegisterLastName" type="text" name="lastname" value="[+post.lastname+]" />
      			</label>
      



      • Copy all contents. create new chunk called "defaultRegisterInstantFormTpl" (without quotes). paste contents into chunk and save

      • [li]In your registration call you should include &customFields
        e.g.
      [!WebLoginPE? &type=`register` &registerTpl=`defaultRegisterInstantFormTpl`  &regRequired=`email,username,firstname,lastname`  &customFields=`firstname,lastname` !]
      

      • Then do whatever you do with Jot, by calling the placeholder corresponding the field name...and please share it here
        • 26310
        • 130 Posts
        I figured that would be the most efficient way of dealing with it. Once I wrap up this site (first full modx based) i’ll be posting quite a few about what I did. These forums have been awesome at helping with everything.
          I twitch because I care....and drink too much coffee.
          • 27442
          • 103 Posts
          I did this not too long ago and went one step further. This is for an alumni website where some of the users registering might have both a ’maiden’ and ’married’ last name. You can just skip the married name parts & remove the related ’if’ logic if yo don’t need that.

          The registration call: (Note the custom fields and that firstname & lastname are required, but not marriedname):
          [!WebLoginPE? &type=`register` &regType=`instant` &registerTpl=`SignUpForm` &groups=`Pending Users` &customFields=`firstname,lastname,marriedname,emailprivate,phoneprivate,mobilephoneprivate,address1private,dobprivate,website,aim,aimprivate,msn,msnprivate,yahoo,yahooprivate,myspace,myspaceprivate,facebook,facebookprivate,city,address1` &inputHandler=`Keep private:userProfileEmailPrivate:emailprivate:checkbox:()||Keep private:userProfilePhonePrivate:phoneprivate:checkbox:()||Keep private:userProfileMobilePhonePrivate:mobilephoneprivate:checkbox:()||Keep private:userProfileAddress1Private:address1private:checkbox:()||Keep private:userProfileDOBPrivate:dobprivate:checkbox:()||Keep private:userProfileAIMPrivate:aimprivate:checkbox:() ||Keep private:userProfileMSNPrivate:msnprivate:checkbox:()||Keep private:userProfileYahooPrivate:yahooprivate:checkbox:()||Keep private:userProfileMyspacePrivate:myspaceprivate:checkbox:()||Keep private:userProfileFacebookPrivate:facebookprivate:checkbox:()` &notify=`[email protected],[email protected]` &notifyTpl=`NotifyAdmin` &pruneDays=`365` &regSuccessId=`57` &regSuccessPause=`0` &regRequired=`email,username,firstname,lastname,password,tos` &liHomeId=`56,48`!]</p>


          Then, a small hack in webloginpe.class around line 418 (the block below starts at 405 for reference):
          	function Register($regType, $groups, $regRequired, $notify, $notifyTpl, $notifySubject)
          	{
          		global $modx;
          		
          		$web_users = $modx->getFullTableName('web_users');
          		$web_user_attributes = $modx->getFullTableName('web_user_attributes');
          		$web_groups = $modx->getFullTableName('web_groups');
          		$webgroup_names = $modx->getFullTableName('webgroup_names');
          		
          		$username = $_POST['username'];
          		$this->Username = $username;
          	    $password = $modx->db->escape($modx->stripTags($_POST['password']));
          		$passwordConfirm = $modx->db->escape($modx->stripTags($_POST['password_confirm']));
          //		edited by sjh_vt Oct 4, 2008
          //	    $fullname = $modx->db->escape($modx->stripTags($_POST['fullname']));
          		if ($_POST['marriedname']=='')
          	    $fullname = $modx->db->escape($modx->stripTags($_POST['firstname'].' '.$_POST['lastname']));
          		else
              	    $fullname = $modx->db->escape($modx->stripTags($_POST['firstname'].' ('.$_POST['lastname'].') '.$_POST['marriedname']));
          //
          	    $email = $modx->db->escape($modx->stripTags($_POST['email']));
          	    $phone = $modx->db->escape($modx->stripTags($_POST['phone']));
          		$mobilephone = $modx->db->escape($modx->stripTags($_POST['mobilephone']));
          		$fax = $modx->db->escape($modx->stripTags($_POST['fax']));
          		$dob = $modx->db->escape($modx->stripTags($_POST['dob']));
          		$gender = $modx->db->escape($modx->stripTags($_POST['gender']));
          	    $country = $modx->db->escape($modx->stripTags($_POST['country']));
          	    $state = $modx->db->escape($modx->stripTags($_POST['state']));
          	    $zip = $modx->db->escape($modx->stripTags($_POST['zip']));
          		$comment = $modx->db->escape($modx->stripTags($_POST['comment']));
          		$cachepwd = time();
          		
          		// Check for required fields.
          


          Obviously, the actual login form has these fields clearly explained. And for what it’s worth, the version of WLPE that I used for this was 1.3.1 in case there are differences between versions. The actual registration page if you’re interested is at http://www.spauldingclassof87.net/home/register.html