Buy Now
Sign in

php get user id after user registration

Timoa , August 26 2021, 10:46
T
Timoa 4
August 26 2021, 10:46 #396992
Hello
In PHP code I need to get user id after joomla user registration. But I don't know how to do that All my experiments have failed.
I have tried this:
$this->get("joomla_user_82.var.id");
$form->data['joomla_user_82']['var']['id'];
but there was no success to get user id...
    [joomla_user_82] => Array
(
[_success] => User saved successfully under id 4543
[var] => Array
(
[name] => Timo Shḱasie
[username] => timoa
[email] => test@gmail.com
[password] =>
[block] => 1
[activation] => d1e38289-2327-4211-b97f-fda91306e9a2
[registerDate] => 2021-08-26 10:32:51
[id] => 4543
)

)
T
Timoa 4
August 26 2021, 22:37 #396994
OK....one solution that works is this
$db = JFactory::getDBO();
$db->setQuery('SELECT id FROM #__users WHERE username = ' . $this->data("username"));
$user_id = $db->loadResult();