Support

  1. morgan_leecy
  2. Support
  3. Thursday, September 07 2017, 04:23 PM
I have been successfully using skeleton.php since I knew if its existence, but for the first time I find myself needed a process that fires on the creation of a new account.

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
morgan_leecy Accepted Answer
Pro
For some reason I cannot accept your answer
  1. more than a month ago
  2. Support
  3. # 1
morgan_leecy Accepted Answer
Pro
Sorry, yes that works fine. I had an error of a different kind which was having a knock on effect. Thanks!
  1. more than a month ago
  2. Support
  3. # 2
admin Accepted Answer
Admin
Hi,
I have just tried $user->id and works.

my code to test it

public function triggerProfileUpdate($user,&$data,$changed,$isNew)
{
if( $isNew ){
print_r( $user->id ) ;
die();
}
}
  1. more than a month ago
  2. Support
  3. # 3
morgan_leecy Accepted Answer
Pro
Of course that code is wrapped in


public function triggerProfileUpdate($user,&$data,$changed,$isNew)
{

//my code

}


cant edit OP to add this line
  1. more than a month ago
  2. Support
  3. # 4
  • Page :
  • 1


There are no replies made for this post yet.
However, you are not allowed to reply to this post.

Request Support

Support is currently Offline

Support Availability

Working days: Monday to Friday. The support staff is not available on weekends; in the most of cases tickets will not be answered during that time.

Reply time: Depending on the complexity of your support issue it's usually between a few minutes and 24 hours for paid members and about one week for free members. When we expect longer delays we will notify you.

Guidelines

Before you post: read the documentation and search the forums for an answer to your question.

When you post: include Site Details if you request a support (you can use the form below the reply in Site Details tab).

Auto Solved Question: If after a week the author of the post does not reply to a request by moderator, the question will be marked as resolved.

Language: only English

Search Users

Easy Profile® is not affiliated with or endorsed by Open Source Matters or the Joomla Project. Joomla is Free Software released under the GNU/GPL License.