-
- 136 Posts
Is there a way to track a user's joined date? I would need it to (ideally) show up in the manager area and be stored in the user attributes table for download. Pretty much identical to how the Last Login Date is working, just with the joined date instead.
Thanks for any help!
[ed. note: firebot6 last edited this post 12 years, 7 months ago.]
-
- 24,544 Posts
I think that would best be done with an extended user field set by a postHook with the ConfirmRegister snippet.
The code to set the field would look something like this (untested):
$profile = $user->getOne('Profile');
$extended = $profile->get('extended');
$extended['joined_date'] = time();
$profile->set('extended', $extended);
$profile->save();
You could also use an unused field in the user profile (e.g., zip) to store the date, which might be somewhat faster and easier.
$profile = $user->getOne('profile');
$date = time();
$profile->set('zip', $date);
$profile->save();
[ed. note: BobRay last edited this post 12 years, 7 months ago.]
-
- 24,544 Posts
Those are unix timestamps (the number of seconds since January 1 1970), but you can use output modifiers to format them when you need to display them -- e.g.,
:strtotime:date=`%m-%d-%Y`
You should definitely use a postHook rather than modifying the snippet code. Your changes to the snippet code would be overwritten every time you update the snippet.
-
- 24,544 Posts
I can't tell from the docs whether ConfirmRegister does postHooks or not, but it does fire the OnUserActivate event, so if you put that exact code in a plugin connected to OnUserActivate, it should work fine.
Note that if you deactivate and reactivate a user, it may (or may not) reset the joined date.
-
- 136 Posts
Using a plugin did the trick. I completely missed that line in the documentation.
Thanks!
-
- 24,544 Posts
I'm glad it worked for you.