I have a custom user registration form and I wish to only allow existing members of my organisaton to register. I have a table loaded with current member details including Member_Nbr (the registration username and email, and the idea was to use a Custom Server Side validation to search for a the member record and confirm that the email address is the same.
I created the basic form with no Validation, it works fine with no validation event.
Then I dragged a Custom Server Side Validation into the On Submit action and added the following:
<?php
$db =& JFactory::getDBO();
$query = "
SELECT COUNT *
FROM `#__glid_chronoforms_data_Member_Profile`
WHERE `Member_Nbr` = '{$form->data['input_username]}' AND
'Email' = '{$form->data['input_email']}' ;
";
$db->setQuery($query);
$count = $db->loadResult();
if ( $count = 0 ) {
$form->validation_errors['input_username'] = "Member Nbr or Email does not exist, or they do not match.";
return false;
}
?>
I placed an event loop in the On Fail area of the Custom Validation Event and now the form fails the validation every time however no validation error appears after the Event Loop.
This behaviour is the same whether I enter a valid combination or not. I have confirmed with phpMySQL that I have a row containing the pair of values I am entering and the SQL (with appropriate values substituted) returns the row.
I placed a Debugger in there and got this:
Data Array:
Array
(
[chronoform] => GFA_Registration
[event] => submit
[option] => com_chronoforms
[Itemid] =>
[input_mbr_name] => Tim Shirley
[input_username] => M-13287
[input_email] => xxxx@yyy.com
[input_password] => zzzzz
[input_password_v] => zzzzz
[input_submit_7] => Submit
[4c8084541de1b08e1015bc06b62d5665] => 1
[name] => Tim Shirley
[username] => M-13287
[email] => xxxx@yyy.com
[password] => zzzzz
[password2] => zzzzz
[_PLUGINS_] => Array
(
[joomla_registration] => Array
(
[*isRoot] =>
[id] => 432
[name] => Tim Shirley
[username] => M-13287
[email] => xxxx@yyy.com
[password] => 3761d623af0edc5719a3053386fd4df9:xFX0cv07W9IyQOUTvzee8OywClrI4jrd
[password_clear] => zzzzz
[usertype] => deprecated
[block] => 1
[sendEmail] => 0
[registerDate] => 2014-05-05 00:19:21
[lastvisitDate] =>
[activation] => 8ef5e5b831bab240fc35ad9ed9127caf
[groups] => Array
(
[0] => 2
)
[lastResetTime] =>
[resetCount] =>
[*_params] => JRegistry Object
(
[data:protected] => stdClass Object
(
)
)
[*_authGroups] => Array
(
[0] => 1
)
[*_authLevels] => Array
(
[0] => 1
[1] => 1
)
[*_authActions] =>
[*_errorMsg] =>
[*_errors] => Array
(
)
[aid] => 0
[chronoform] => GFA_Registration
[event] => submit
[option] => com_chronoforms
[Itemid] =>
[input_mbr_name] => Tim Shirley
[input_username] => M-13287
[input_email] => xxxx@yyy.com
[input_password] => zzzzz
[input_password_v] => zzzzz
[input_submit_7] => Submit
[4c8084541de1b08e1015bc06b62d5665] => 1
[password2] => zzzzz
)
)
[User] => Array
(
[*isRoot] =>
[id] => 432
[name] => Tim Shirley
[username] => M-13287
[email] => xxxx@yyy.com
[password] => 3761d623af0edc5719a3053386fd4df9:xFX0cv07W9IyQOUTvzee8OywClrI4jrd
[password_clear] => zzzzz
[usertype] => deprecated
[block] => 1
[sendEmail] => 0
[registerDate] => 2014-05-05 00:19:21
[lastvisitDate] =>
[activation] => 8ef5e5b831bab240fc35ad9ed9127caf
[groups] => Array
(
[0] => 2
)
[lastResetTime] =>
[resetCount] =>
[*_params] => JRegistry Object
(
[data:protected] => stdClass Object
(
)
)
[*_authGroups] => Array
(
[0] => 1
)
[*_authLevels] => Array
(
[0] => 1
[1] => 1
)
[*_authActions] =>
[*_errorMsg] =>
[*_errors] => Array
(
)
[aid] => 0
[chronoform] => GFA_Registration
[event] => submit
[option] => com_chronoforms
[Itemid] =>
[input_mbr_name] => Tim Shirley
[input_username] => M-13287
[input_email] => xxxx@yyy.com
[input_password] => zzzzz
[input_password_v] => zzzzz
[input_submit_7] => Submit
[4c8084541de1b08e1015bc06b62d5665] => 1
[password2] => zzzzz
)
)
Validation Errors:
Array
(
)
So I am puzzled.
1. Why would this code always return a fail?
2. Why does the error message not appear, since the code is failing?
Cheers
Tim