Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.
Member's Time Zone
rdilauro
New
We recently migrated from Drupal to Vanilla 2.2 In Drupal, from the member's profile they could set their own time zone. Is there a way in Vanilla that allows each member to do this?
0
Comments
Unfortunately I can't find an obvious way of setting your own timezone by default, but:
User timezone is recorded by default, so a simple plugin (or a default function I'm missing) could change this. Though I'd test to see if users could get around time-gated functions - like post editing - by changing their timezone or anything strange like that
You would have to add a new option to the profile. Using the profile extender is quite easy, but it wouldn't be possible in this case... More on that later.
The field that is responsible for the users time is in table User: HourOffset.
Every time the user signs in, the clients hour offset is compared with User->HourOffset. If they are not the same, HourOffset is updated.
https://github.com/vanilla/vanilla/blob/master/applications/dashboard/controllers/class.entrycontroller.php#L896-L904
https://github.com/vanilla/vanilla/blob/master/applications/dashboard/controllers/class.entrycontroller.php#L954-L956
So you would have to take care for 2 changes:
1. changing the offset after a signin. Do this by creating a method
public function userModel_afterSignIn_handler($sender, $args) {}
in your plugin2. after a user has changed his settings, the HourOffset has to be changed, too
The ProfileExtender plugin doesn't expose an option to react on changes (please correct me if I'm wron, @Linc). It uses UserModels setMeta which also doesn't have an option to react on a change. That's why you would have to create your custom field without the profile extender.
There's also a seldom used function "setClientHour" and in order to avoid any changes on the HourOffset field, you would have to create a
userModel_afterSetField_handler($sender, $args)
Although it doesn't sound like that, I'd guess it is a quite easy plugin to write...
The client hour offset is updated via JS, so you would need to disable/override that setting as well. https://github.com/vanilla/vanilla/blob/d4c9bccedaa609f30c4df68bec44c6151e401feb/js/global.js#L1182-L1197
That gets executed on document ready.
Search first
Check out the Documentation! We are always looking for new content and pull requests.
Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.