Forums

cf_joomla_registration problem

rmsmall 26 Sep, 2012
Hi,

I am having trouble debugging the below code. The first statement if (!$user->save()) I believe goes into an infinite loop (the browser window goes blank and there is no source code). I don't know where to look for the save function to determine what is happening.

Any help would be greatly appreciated.

Thanks

Alan

       // If there was an error with registration, set the message and display form
echo "start save";
        if ( !$user->save() ) {
            $MyPlugins->cf_joomla_registration['errors'] = JText::_( $user->getError());
            $messages[] = JText::_( $user->getError());
            if ( $params->get('showmessages') ) {
                //$mainframe->enqueuemessage(JText::_( $user->getError()), 'error');
				$MyForm->addErrorMsg(JText::_( $user->getError()));
            }
            if ( $params->get('debugging') ) {
                $helper->showPluginDebugMessages($messages);
            }
            // remove the password values from display
            $post['password']  = $post[$params->get('pass')]  = '';
            $post['password2'] = $post[$params->get('vpass')] = '';
            $MyForm->showForm($MyForm->formrow->name, $post);
            return false;
        }
GreyHead 27 Sep, 2012
Hi Alan,

What are you trying to achieve here? It looks as though you have lifted a chunk of code from one of the ChronoForms actions. There's no problem with that but the code will only work if you also make sure that all the variables are defined. I can see $user, $params, $helper here which don't appear to have any values set in this snippet.

Bob
rmsmall 27 Sep, 2012
Hi Bob,

Thanks for the reply. I lifted the snipped out of cf_joomla_registration. I have been debugging it and it appears to be working fine until it hits the line of code " if ( !$user->save() )"
I am no expert at php and am getting lost trying to figure out what it executes here. I am looking for help where to look for the code under save() so I can continue to debug.

Thanks very much

Alan
GreyHead 27 Sep, 2012
Hi Alan,

What are you trying to achieve here? There may be an easier way.

The $user->save() code comes from the Joomla! User library libraries/Joomla/user/user.php around line 715 but I think that is just extending the method from the Joomla! Database class.

Bob
rmsmall 27 Sep, 2012
Hi Bob,

The code stops executing at that point and I am just trying to figure out why. When it hits this line the browser opens up to a url something like http://domain/chronoformid and when I do a view source there is no code to view.
The code is actually integrated with Infusionsoft and the user is created there, then it is supposed to be created in Joomla but this does not happen. I am just trying to figure out where it is failing and why. As far as I can tell it gets to that save() call and then it does nothing further.
I would love an easier way to figure this out as I have spent a couple of hours on this already.

Thanks very much.

Alan
GreyHead 27 Sep, 2012
Hi Alan,

Try setting Error Reporting to Maximum in the site Global Configuration - that should give you a more meaningful error message on the blank page.

Bob
rmsmall 27 Sep, 2012
Thank you I have tried that but it still gives me a blank page. It also will not return any values I try to echo in that save function, so it appears to not get that far. I think the values in $user look ok. I'm kind of at a loss where to go from here. Appreciate any ideas.

Thanks

Alan
GreyHead 27 Sep, 2012
Hi Alan,

I still have no idea what you are trying to do here so hard to make suggestions :-(

Presumably there is some code before this where you have opened the user object and set the user parameters you are trying to save?

Bob
rmsmall 27 Sep, 2012
Hi Bob,

I have a Chronoform that is trying to create a user in Infusionsoft, then create the same user in Joomla. So I am using cf_joomla_registration to accomplish this from the Joomla side.

Presumably the $user parameters do get set when I configure cf_joomla_registration, and the values look good right up until the save call is made. Here are what selected values look like:

Array (
[5] => Contact0FirstName [5] => first
[6] => Contact0LastName [6] => last
[7] => Contact0Email [7] => [email]aa@rmsmallbusiness.com[/email]
[8] => Contact0Username [8] => username
[9] => Contact0Password [9] => pw
[10] => ConfirmPassword [10] => pw
[29] => chronoformname [29] => freetrial
[30] => username [30] => username
[31] => name [31] => first
[32] => email [32] => [email]aa@rmsmallbusiness.com[/email]
[33] => password [33] => 6fbf56835cb1575a49b541bb4f769739:J7L9WqI2RbWU8MKqm3g2n4jfGfJtRQuO
[34] => password2 ) [34] => pw

They all look correct to me except for password2 not sure if this is a problem.

So when I complete the form and click submit I end up at a url like this:
http://theinevitableyou.com/index.php?option=com_chronocontact&task=send&chronoformname=freetrial&Itemid=89 and the form is blank except for anything I want to output prior to that call to save().

Itemid 89 is the correct menu item.

If I complete the form using an existing username I get an error that the user already exists, so it does communicate with the database.

So my suspicion is that something is going wrong in the call to save() that is preventing the user from being created but I cannot figure out what that might be.

I have created a small test form that does not invoke infusionsoft at all and I get the following result -
If I disable cf_joomla_registration the form works fine and I get all my debug messages
If I enable cf_joomla_registration the blank page appears.

Not sure what else you need to know.

Thanks very much.

Alan
GreyHead 28 Sep, 2012
Hi Andy,

Passwords are tricky and the Joomla! code uses both plain text and encrypted hashes. You';d need to check the original code to see exactly which version is needed where.

I'm still a bit lost about why you are re-coding this. It ought to be possible to add your InfusionSoft data to the $form->data array and then call the ChronoForms Joomla! Registration action to handle the Joomla! Registration.

Bob
rmsmall 28 Sep, 2012
Hi Bob,

Please forgive my ignorance on this but what do you mean by "add my infusionsoft data to the $form->data array"? And then "call the joomla registration action"? Would you please explain this in terms of chronoforms functionality?

Thanks very much.

Alan
GreyHead 28 Sep, 2012
Hi Alan,

ChronoForms stores form results in the $form->data array. The ChronoForms actions look at that array and use the data there to carry out whatever it is they do.

However, ChronoForms doesn't know where the data comes from so if you add data to the $form->data array - for example in a Custom Code action - then ChronoForms will happily work with it.

So if you have data from the Infusionsoft registration that says the 'username' for example is 'XXX' then you can tell ChronoForms to set $form->data['username'] = 'xxx'; in a Custom Code action and then use username in the corresponding box of the Joomla! User Registration action. And the same for each of the other values.

Bob
This topic is locked and no more replies can be posted.