MODX Community

Login.Register not creating User

I’m using to login snippet for my website and all the other aspects of it are working with the exception of login.register which after going over the documentation multiple times should be. All the form fields are named correctly. I’m at a loss at this point and would appreciate some help if possible.
This is my general form and snippet call

[[!Register? &emailField=`company-email` &submittedResourceId=`1` &usergroups=`Members` &activation=`0`]]

    <form action="[[~[[*id]]]]" class="form" id="registration-form">
        <div class="row form-section current">
          <label class="col-12 form-label form-label-full">Company Name
             <input type="text" class="form-control" autofocus name="company-name" id="companyName" required>
          </label>
          <label class="col-md-6 form-label form-label-full">Company Phone Number
             <input type="tel" class="form-control" name="company-phone" id="companyPhone" required>
          </label>
          <label class="col-md-6 form-label form-label-full">Company Email Address
              <input type="email" class="form-control" name="company-email" id="companyEmail" required>
          </label>
          <label class="col-md-10 form-label form-label-full">Street Address
             <input type="text" class="form-control _address" name="company-address" id="companyAddress" required>
          </label>
          <label class="col-md-6 form-label form-label-full">City
            <input type="text" class="form-control _address" name="company-city" id="companyCity" required>
          </label>
          <label class="col-md-3 form-label form-label-full">State
            <select name="state" class="form-control _address" id="companyState" required>
                <option value="" selected disabled>---</option>
                [[!FormItStateOptions? &selected=`[[!+state]]`]]
            </select>
          </label>
          <label class="col-md-3 form-label form-label-full">Zip Code
             <input type="text" class="form-control _address" name="company-zip" id="registrationZip" required>
          </label>
          <label class="col-md-6 form-label form-label-full">Username
            <input type="text" class="form-control" name="username" id="createUsername" required>
          </label>
          <label class="col-md-6 form-label form-label-full">Create Password
           <input type="password" class="form-control" name="password" id="createPassword" required>
          </label>
          <input type="submit" class="btn btn-outline pull-right w-100" name="login-register-btn" id="login-register-btn">
        </div>
</form>

MODx version 2.7.2
all packaged are up to date

In the example here there is an activation resource id, I see you don’t want the user activated, but not sure if this could be necessary to user creation.

I also notice you have used a different id number for the username, and the code around that is different, don’t you need a ‘value’ reference?

        <label for="username">[[%register.username? &namespace=`login` &topic=`register`]]
            <span class="error">[[!+reg.error.username]]</span>
        </label>
        <input type="text" name="username" id="username" value="[[!+reg.username]]" />
1 Like

In the example that @nuan88 has linked to there is this in the snippet call:

&submitVar=`registerbtn`

The submit button has that submitVar as its name:

name="registerbtn"

I think that without those names matching up the submit button does not do anything.

2 Likes

@nuan88 all the activation does is set the user to active it does not stop the user from being made (according to the documentation) and the value reference [[!+reg.username]] is just a place holder that puts the value back if the form should fail to submit (to my knowledge and reference off of formit) as for the id being different i changed it and it didnt help.

@andytough you are correct but the name i have “login-register-btn” is the default value for that option.

edit: i tried both of your suggestions in case i am wrong(which definitely might be the case) but got nada

1 Like

login-register-btn is definitely ok and there might be one more that also works.

Members is a defined class of users?

I have never seen the required put into the code like that…usually the required statements go in the call itself

1 Like

@nuan88 tried multple different names with the submitVar option to no avail, and after double checking yes Members is class of users and should be one of the defaults, and the required in the input is an html5 validation

1 Like

login is finicky, strip the call down to the bare bones, make sure it works, and add in pieces one by one, or build in validation so we can get some output…nothing in the error log?

1 Like

nope nothing in the error log and yes i am going to try to strip it down to bare bones again

1 Like

Hi, @nuan88 is correct regarding the need to have an input value like the [[!+reg.username]] one for all of the fields. This is what takes the value the user inputs and places it in the database.

<label for="username">[[%register.username? &namespace=`login` &topic=`register`]]
    <span class="error">[[!+reg.error.username]]</span>
</label>
<input type="text" name="username" id="username" value="[[!+reg.username]]" />

I think you will need to stick to default field names. If you wish to have custom field names like companyAddress you should take a look at @bobray 's excellent ClassExtender

2 Likes

Thanks for your expertise, Andy. Its all a bit Greek to me

thanks @andytough, but i already tried that yesterday and again this morning and it not working

1 Like

My advice is to start with the working example, make sure it works, and then only change the things that must be changed, and very slowly.

You’ve gotten so far away from the example and I don’t think that will be helpful, and it seems to have no purpose really. Start with the working example.

1 Like