Forums

Joomla Registration Plugin failure not catched

nevermind85 13 Apr, 2009
Hi, as many, I'm trying to create a registration form that replaces Joomla's one because I want only publishers or admins to create users; and I want some custom fields for them.

I've activated the Joomla registration plugin and i've created a new table for the form, after Submit, the form is supposed to:
a) Create the new user
b) Store the additional fields on the new table.

So far everything works as expected: Joomla user is created, and data is stored to the table; however I think I encountered an error. While I was testing the form, I decided to use the same email address for the new test user than the email of an existing user. The result was that the Joomla account was not created, no error was returned, and the additional data was stored on the form table.

Here's the debug output:
   1. Form passed first SPAM check OK
   2. Form passed the submissions limit (if enabled) OK
   3. Form passed the Image verification (if enabled) OK
   4. Form passed the server side validation (if enabled) OK
   5. $_POST Array: Array ( [txtName] => test [txtUsername] => test [txtEmail] => test@server.com [txtPwd] => 123 [txtPwdchk] => 123 [txtAddr] => 123 [ddState] => 2 [ddCity] => 25 [txtPhone] => 123 [txtURL] => 123 [52725d7916e7e57b3276706e716eedd8] => 1 )
   6. $_FILES Array: Array ( )
   7. Form passed the plugins step (if enabled) OK
   8. Debug End


Here's the "Run Order":
1) Plugins
2) OnSubmit
3) Autogenerated

The expected result was that if the plugin step failed, everything else should fail as well, hence, OnSubmit (which I have empty) is not ran, neither is the Autogenerated code that stores the extra data on the form's associated table. I've been looking for some place to "Enable" the "Form passed the plugins step" option the Debug output mentions but I can't seem to find it. Furthermore, I can see that the Plugin has a "Registration result" key = $MyPlugins->cf_joomla_registration['complete'], but I don't know how to use that (if I can anyway) to evaluate the result (as I could on the OnSubmit block, for example).

These are the versions I'm using:
Joomla! 1.5.10
ChronoConnectivity V1.2
ChronoForms V3.1 RC4.11
Plugin_chronocontact V3.1 RC4.11

Ideas?
GreyHead 13 Apr, 2009
Hi nevermind85,

IIRC the plugin doesn't add any extra checks (though perhaps it should) - those need to be coded separately. You can do them very easily in server-side validation. With 4.11 Max built in some code to support Ajax and it should be possible to add client-side checks too.

Bob
nevermind85 13 Apr, 2009
Hi, and thanks for the quick response.

Here's part of the plugin php code (cf_joomla_registration.php file, on the components\com_chronocontact\plugins folder):
		// If there was an error with registration, set the message and display form
		if ( !$user->save() )
		{
			//JError::raiseWarning('', JText::_( $user->getError()));			
			$MyPlugins->cf_joomla_registration['errors'] = JText::_( $user->getError());
			return false;
		}

Perhaps this rings a bell? I believe the plugin should provide the user with a success/failure output, at least that's what the Debug output on 7 seems to imply...
Max_admin 14 Apr, 2009
Hi nevermind85,

as you can see from the code, you can access any error happened during the registration through this:


$MyForm =& CFChronoForm::getInstance();
$MyPlugins =& CFPlugins::getInstance($MyForm->formrow->id);
if($MyPlugins->cf_joomla_registration['errors']){
return $MyPlugins->cf_joomla_registration['errors'];
}


the code above if added to the server side validation will show an error if exists!

Regards
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
nevermind85 14 Apr, 2009
Thanks admin, however it doesn't work for me. The form gets submitted, the extra data is added, but the new user is not registered.

I've checked that this happens also if the username matches an existing one.

Here's my server side validation code after using your snippet:
<?php
global $mainframe;
if(JRequest::getVar('txtPwd') != JRequest::getVar('txtPwdchk'))
return 'Sorry, passwords do not match, try again!';

$MyForm =& CFChronoForm::getInstance();
$MyPlugins =& CFPlugins::getInstance($MyForm->formrow->id);
if($MyPlugins->cf_joomla_registration['errors']){
return $MyPlugins->cf_joomla_registration['errors'];
}
?>
Max_admin 14 Apr, 2009
Hi nevermind85,

does the new user get added when you use new unique data ? I mean does it work if there is no errors ?

Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
nevermind85 15 Apr, 2009

does the new user get added when you use new unique data ? I mean does it work if there is no errors ?


Hi Max, thanks again for the quick response. Yes, if unique data is entered the registration works, so the plugin is running fine.

and please try this too:
http://www.chronoengine.com/forums/index.php?option=com_chronoforums&cont=posts&f=2&t=13769#p29072

although it does the same task!

Cheers
Max



Ok, using that last piece of code worked. However I had to set up the form "Email the results?" to Yes for the On Submit before email code to work. I thought that was excecuted even if Email the results was set to No?.

To summarize, this is how everything should be set:

Form config:
Email the results: Yes
On Submit code - before sending email:
<?php
$MyForm =& CFChronoForm::getInstance();
$MyPlugins =& CFPlugins::getInstance($MyForm->formrow->id);
if($MyPlugins->cf_joomla_registration['errors']){
$MyForm->stoprunning = true;
$MyForm->formerrors = $MyPlugins->cf_joomla_registration['errors'];
$MyForm->showForm($MyForm->formrow->name, $posted);
}
?>

Joomla Registration Plugin config:
Run Before/After the Email: Before Email

You might want to add this on the pdf tutorial😉

And by the way, I can use Ajax on the form code HTML / Javascript, it's pretty neat even tho I have to use an external php file to process what I need (it's basically a State->City query). Having this on a Client Side validation would be very useful.
Max_admin 15 Apr, 2009
Hi,

Glad you made it, looking at the piece of code that didn't work, I see why it didn't work now, that's because at the server side validation step, there is no plugins run yet and so no errors! 😲

at the next release, there will be an easy way to run JSON code using the extra boxes in the extra tab, so instead of adding your PHP AJAX code in a PHP file, you will simply add it to the extra box!

Regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
This topic is locked and no more replies can be posted.