"cf_user_id" field joomla registration plugin cfv4 rc3.3

rmpaolillo 31 May, 2012
Hi,
I have used in the past the CFv3 together with the joomla registration plugin to manage registration and create/connect an extra table to collect more user information (first name, last name, phone no. etc.) than those allowed by joomla.

With CFv3 in the extra table I could see that the "cf_user_id" field match with the "id" field in the standard user joomla table.

With CFv4 RC3.3 I am trying to reach the same result.

Everything works fine but the "cf_user_id" in the extra table always is zero.
I have played around a bit but with no success.

Any help is appreciated.

Marco
Max_admin 31 May, 2012
Answer
1 Likes
Hi Marco,

V4 will fill the "cf_user_id" with the "logged in" user's id, not the created one, if you need the last created user id then you will need to add a new "user_id" folumn to your table and set its value using a "Custom code" action:


<?php
$form->data['user_id'] = $form->data['_PLUGINS_']['joomla_registration']['id'];
?>


Regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
rmpaolillo 31 May, 2012
Hi Max,

thanks for your prompt reply.

It worked like a charm.

I post some screenshot just in case some newbie to CFv4 needs it.

Regards.

Marco
GreyHead 31 May, 2012
1 Likes
Hi Marco,

After the Joomla! Registration action the new user data is placed in $form->data['_PLUGINS_']['joomla_registration'] You should be able to get the user id from $form->data['_PLUGINS_']['joomla_registration']->id

Bob

PS I recommend that you don't use the On Success events for the main actions, put them after the action in the On Submit event instead.
rmpaolillo 31 May, 2012
Hi Bob,

according to what you say I might reach the same result as in CF3 and as requested in my original post by using


<?php
$form->data['cf_user_id'] = $form->data['_PLUGINS_']['joomla_registration']['id'];
?>


and indeed it works (still I have not tested if any drawback is behind the corner).

Thank you for the recommendations about the main actions. I guess your suggestion holds until there is an "event loop" in the "on fail" event of the Joomla User Registration plugin that catches the error and stops from executing additional actions in on "on submit" event.
GreyHead 31 May, 2012
1 Likes
Hi Marco,

Yes that code looks good.

And yes, the ChronoForms flow will continue through the On Submit event until some action, like an Event Loop, stops it.

Please see the Basics 2 tutorial here for more on actions and events in CFv4.

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