Ok, so I’m no php expert, nor am I a modx expert. Really more of a hack and brand new to Modx, although I’m learning relatively quickly.
I have a problem, though, that I can’t find a solution to in the forums.
I have a script that I’m submitting a form to, which is then passing the form data through the URL to a form hosted on ModX and using WEbLoginPE.
I am having no trouble getting the data pulled from the URL and populated into the form on ModX.
However, if this form is submitted with a missing field, and WebLoginPE reloads the page with the error message, some of the fields are not repopulating, while others are.
I have a snippet that looks like:
$affiliateid = $_GET['custom_affiliateid'];
$affiliatefirst = $_GET['custom_affiliatefirst'];
$affiliatelast = $_GET['custom_affiliatelast'];
$affiliateurl = $_GET['custom_affiliateurl'];
$affiliatezo = $_GET['custom_affiliatezo'];
$affiliateurltext = $_GET['custom_affiliateurltext'];
$affiliatedistributor = $_GET['custom_affiliatedistributor'];
$affiliatebrand = $_GET['custom_affiliatebrand'];
$first = $_GET['first_name'];
$email = $_GET['email'];
echo "<input type='hidden' id='wlpeRegisterAffiliateid' name='affiliateid' value='".$affiliateid."[+post.affiliateid+]' />
<input type='hidden' id='wlpeRegisterAffiliatefirst' name='affiliatefirst' value='".$affiliatefirst."[+post.affiliatefirst+]' />
<input type='hidden' id='wlpeRegisterAffiliatelast' name='affiliatelast' value='".$affiliatelast."[+post.affiliatelast+]' />
<input type='hidden' id='wlpeRegisterAffiliateurl' name='affiliateurl' value='".$affiliateurl."[+post.affiliateurl+]' />
<input type='hidden' id='wlpeRegisterAffiliateurltext' name='affiliateurltext' value='".$affiliateurltext."[+post.affiliateurltext+]' />
<input type='hidden' id='wlpeRegisterAffiliatezo' name='affiliatezo' value='".$affiliatezo."[+post.affiliatezo+]' />
<input type='hidden' id='wlpeRegisterAffiliatebrand' name='affiliatebrand' value='".$affiliatebrand."[+post.affiliatebrand+]' />
<input type='hidden' id='wlpeRegisterAffiliatedistributor' name='affiliatedistributor' value='".$affiliatedistributor."[+post.affiliatedistributor+]' />
<p>To complete your registration for The Motor Oil Evaluator, you must complete your FULL name, confirm your email address, choose a username for your login and read over and agree to our Terms of Service and Privacy Policy. In a nutshell, it just says that the information you gain from this
site is provided AS IS, with no warranty in regards to its accuracy or its usefulness to you in make business or personal decisions regarding your oil selection.
<p>I may miss a tech spec update here or there or might incorrectly
enter a value occassionally, so let me know if I do. Also, the information is only as useful as the decisions you make from its use. I have no control over your oil selection decisions once you've compared the oils, AND, since you have the
ability to CHANGE the ranking of the oils based upon your own preferences, the actual information you receive from this service MAY differ considerably from what I have actually put forth in the default structure of the listings.
<p>Also, the privacy policy basically just says I won't use your contact information for anything you don't already know about (news, updates, useful product reviews, etc.) and WILL NOT supply your contact information to ANY other business, organization or individual for ANY reason other than a legal mandate.
<fieldset id='wlpeRegisterFieldset' style='border: none;'>
<p class='wlpeRegisterInfo'>Enter your email address, your <b>FULL</b> name, and your desired username in the fields below. A password will be emailed to you with instructions on how to activate Your account, <b>so, please make sure the email you enter is correct</b>.</p>
<label for='wlpeRegisterFullName'><b>Your <i>FULL</i> Name</b><br>
<input type='text' id='wlpeRegisterFullName' name='fullname' value='".$first."[+post.fullname+]' />
</label>
<br>
<label for='wlpeRegisterEmail'><b>Your Email Address</b><br>
<input type='text' id='wlpeRegisterEmail' name='email' value='".$email."[+post.email+]' />
</label>
<br>
<label for='wlpeRegisterUserName'><b>Your desired username</b><br>
<input type='text' id='wlpeRegisterUserName' name='username' value='[+post.username+]' />
</label>
When a user registers for an account on this Modx site using the form above, I want not only their information submitted to the database, but also the information related to the affiliate that referred them.
This data is pulled from the URL as it has been passed on from a previous form submission.
On the new form, all fields populate initially. However, if the user doesn’t fill out a field, like checking the TOS box, when the page reloads with the error message, all of the affiliate info fields have been blanked.
The snippet I posted above is called by a chunk:
[+wlpe.message+]
<div id="wlpeRegister">
<form id="wlpeRegisterForm" name="wlpeRegisterForm" action="[~[*id*]~]" method="POST">
[[PHPHeader]]
[+tos+]
<input type="checkbox" id="wlpeRegistertos" name="tos" /> I agree to the terms of service
</fieldset><br><br>
<fieldset id="wlpeRegisterButtonFieldset" style='border: none;'>
<button type="submit" id="wlpeRegisterButton" name="service" value="register">Register</button>
<button type="submit" id="wlpeRegisterCancelButton" name="service" value="cancel">Cancel</button>
</fieldset>
</form>
</div>
And the chunk above is called using the following code in the document content area in Modx:
[!WebLoginPE? &type=`register` ®Type=`verify` ®isterTpl=`UserRegister` &customFields=`affiliateid,affiliatefirst,affiliatelast,affiliateurl,affiliateurltext,affiliatezo,affiliatebrand,affiliatedistributor` &pruneDays=`7` &groups=`Registered Users` &tableCheck=`0` ®Required=`email,username,fullname,tos`!]
On error, when the page reloads, the query strings are cleared from the URL, so they will not repopulate in that manner, which is why I’ve used the "post" placeholders to reinsert that data on error.
What am I doing wrong? Any help would be greatly appreciated as I’ve spent about a 1/2 hour searching the forums for an answer with no success.
Does it have something to do with the fact that they are hidden fields? Not sure why that would matter, but it’s the only difference I can see between the fields that ARE repopulating the data and those that are NOT.
Thanks again.