MyBB Community Forums

Full Version: How to set all users to the same timezone and stop them from changing it
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3
INTRODUCTION

When you edit the timezone settings in the Admin CP, it only affects guests and newly registered users. While registering, you can change your timezone settings. And after registering, you can also change your timezone settings in the User CP. In this tutorial, I will be teaching you how to set all users to the same timezone and disable them from editing it in the future.

TUTORIAL

1. Go to Admin CP > Configuration > Settings > Date and Time Formats.

2. Select your timezone from Default Timezone Offset and choose whether to enable DST or not from Day Light Savings Time.

3. Go to Admin CP > Templates & Style > Templates > Your Template Set > Member Templates > member_register.

4. Find and remove:

<fieldset class="trow2">
<legend><strong><label for="timezone">{$lang->time_offset}</label></strong></legend>
<table cellspacing="0" cellpadding="{$theme['tablespace']}" width="100%">
<tr>
<td><span class="smalltext">{$lang->time_offset_desc}</span></td>
</tr>
<tr>
<td>{$tzselect}</td>
</tr>
<tr>
<td><span class="smalltext">{$lang->dst_correction}</span></td>
</tr>
<tr>
<td>
	<select name="dstcorrection">
		<option value="2" {$dst_auto_selected}>{$lang->dst_correction_auto}</option>
		<option value="1" {$dst_enabled_selected}>{$lang->dst_correction_enabled}</option>
		<option value="0" {$dst_disabled_selected}>{$lang->dst_correction_disabled}</option>
	</select>
</td>
</tr>
</table>
</fieldset>
<br />

5. Go to Admin CP > Templates & Style > Templates > Your Template Set > User Control Panel Templates > usercp_options.

6. Find and remove:

<tr>
<td><span class="smalltext">{$lang->time_offset_desc}</span></td>
</tr>
<tr>
<td>{$tzselect}</td>
</tr>
<tr>
<td><span class="smalltext">{$lang->dst_correction}</span></td>
</tr>
<tr>
<td>
	<select name="dstcorrection">
		<option value="2" {$dst_auto_selected}>{$lang->dst_correction_auto}</option>
		<option value="1" {$dst_enabled_selected}>{$lang->dst_correction_enabled}</option>
		<option value="0" {$dst_disabled_selected}>{$lang->dst_correction_disabled}</option>
	</select>
</td>
</tr>

7. If in step 2 you set Default Timezone Offset to a positive timezone (e.g. GMT +10:00), execute this SQL query (change the 10 to the actual timezone you want):

UPDATE `mybb_users` SET `timezone` = '10'

If in step 2 you set Default Timezone Offset to a negative timezone (e.g. GMT -10:00 Hours), execute this SQL query (change the -10 to the actual timezone you want):

UPDATE `mybb_users` SET `timezone` = '-10'

If in step 2 you set Default Timezone Offset to GMT, execute this SQL query:

UPDATE `mybb_users` SET `timezone` = '0'

8. In order to update all users to use the same setting that you set in Day Light Savings Time, execute this SQL query:

UPDATE `mybb_users` SET `dstcorrection` = '2'

CONCLUSION

If you followed these steps precisely, all users should have the same timezone and will not be able to change them in their User CP or during registration. See the examples below:

[attachment=23198][attachment=23199]
Great work, Faviouz. Very nice, detailed and easy to follow tutorial. Smile
Thanks Jordan. Smile
Can this be implemented with the mybb chat system?
Cause i was using a mybb chat plugin where the timezone varies on the ADMIN timezone.
Hope this one will solve ,y problem. I'll test it later. Thanks.
If the chat plugin uses the timezone settings from the MyBB settings, then yes. Which chat plugin are you using?
thanks for the tut
the SQL query will be executed in the phpmyadmin?
Yes, that is correct.
hello..

Great work..
Its really very good to how the step by step tutorial with all of us...
thanks for helping me..
as i was searching for it..
Pages: 1 2 3