Getting user ID after user registration.

Retrieve the user ID after Joomla registration in ChronoForms.

Overview

The issue occurs because the user ID is not accessible using CFv5 syntax or incorrect placeholder variables.
Use the joomla_user action and reference the ID with the correct placeholder format. For newly inserted database rows, use the appropriate placeholder structure to access the generated ID.

Answered
ChronoForms v6
cy cyberspyder 20 Jul, 2020
Hello! I have a form that I am using to create a user account in Joomla, which works. But then I need the ID of the user to use in other tables (I am also adding them to SobiPro). Here's a link to the form: https://www.eslpassport.com/basic-business-form

If the business name you type doesn't exist, fields are displayed to create an account.

I am using a custom code area after the joomla registration (in the success area) with <?php
$form->data['user_id'] = $form->data['_PLUGINS_']['joomla_registration']['id'];
?>

Then, in the Save Data for the other tables, I try to call that data and insert it, but nothing I've tried works. I have currently {var:user_id} but I have tried {user_id} and {data:user_id}. Everything gives me 0.

I also need to be able to find the last entry in the sobi_objects table so I can link those tables, but I don't know how to do that. I can't use count because some have been deleted. How can I do these 2 things?[file=13170]Business_Registration_Form_Basic_20_Jul_2020_17_19_02.cf6bak[/file]
he healyhatman 20 Jul, 2020
Just use the joomla_user action, and then the id is {var:joomla_user_action_name_goes_here.id}

$form->data['user_id'] won't work because that's CFv5 syntax. You'd want $this->data("user_id", $theInputValue, true)
{data:id} won't work because you're not submitting a form with an "id" input
{user_id} won't work because that's nonsense that doesn't do anything
{user:id} won't work because the user is not logged in yet
{var:user_id} won't work unless you have a PHP block or custom code action called "user_id" that returns the value
cy cyberspyder 21 Jul, 2020
Thank you for resolving that for me. I now have it creating the joomla user and also generating a row in a sobi_object table with the user ID as the owner.

How can I get the ID of this newly inserted row so I can use as a key to add several other rows to a different table with this ID to link them.
cy cyberspyder 21 Jul, 2020
In case it helps, here's what I have so far:
1. I moved the read data down to after the user is created and after the insert into the sobi table happens.
2. I changed the Read Data to pull the first record with that user id and like that name, and return an ID of that entry.
3. I changed the insert to use {var:read_data41}

This gives me a 0 so it's not right. I also tried {var:read_data41:id} but that also didn't work.
cy cyberspyder 22 Jul, 2020
Thank you very much. I am still getting a 0 as my value. [file=13171]Business_Registration_Form_Basic_21_Jul_2020_22_37_45.cf6bak[/file]
I attached the backup file if that helps.
he healyhatman 22 Jul, 2020
That won't work, because I won't have your tables so the save data action will be blank.

Better off showing me a screenshot of your save data action, the part where you're trying to use the newly inserted row's ID, and a copy paste of the debug.
cy cyberspyder 22 Jul, 2020
I am sorry! I didn't think about that! [file=13174]read-action.jpg[/file]
​[file=13175]save-action.jpg[/file]
cy cyberspyder 24 Jul, 2020
Answer
I was able to resolve my issue - the final was to use {var:read_data41.Data41.id}. Thank you for your help! I really do appreciate all you do for this forum. Happy weekend!
This topic is locked and no more replies can be posted.