I need to write the users ID to a third party table, but when a new account is created, the user does not have an ID
Am I using this piece of code correctly (this is an example) or is it not possible for skeleton.php to get the user id of a newly created user at the time of registration submission? I can work around this with a two step registration process but would rather just have one for user experience
I have tried both $data['id'] and $user->id;
if ($isNew) {
// Get a db connection.
$db = JFactory::getDbo();
// Create a new query object.
$query = $db->getQuery(true);
$columns = array ('created_by', 'approved', 'published');
$values = array ( $data['id'], '0', '1');
$query
->insert($db->quoteName('#__my_table'))
->columns($db->quoteName($columns))
->values(implode(',', $values));
$db->setQuery($query);
$db->execute();
}
If this is incorrect, how can I use skeleton.php to grab the id from a newly generate user account so I can use it immediately? or does skeleton.php fire before the account is saved so there is no id?
If the account has been created I suppose I could use
$db->execute();
return $db->insertid();
in skeleton.php to grab the ID
Any guidance appreciated