Forum opening hours

Need some custom code changes to the phpBB core simple enough that you feel doesn't require an extension? Then post your request here so that community members can provide some assistance.

NOTE: NO OFFICIAL SUPPORT IS PROVIDED IN THIS SUB-FORUM
Forum rules
READ: phpBB.com Board-Wide Rules and Regulations

NOTE: NO OFFICIAL SUPPORT IS PROVIDED IN THIS SUB-FORUM
User avatar
bennybernaer
Registered User
Posts: 714
Joined: Tue Mar 22, 2011 9:53 pm

Forum opening hours

Post by bennybernaer »

I'm looking for a way to keep my forum open to users only during certain hours.
(based on the time zone set in the admin panel)

Monday: 8:00 AM - 11:00 PM
Tuesday: 8:00 AM - 11:00 PM
Wednesday: 8:00 AM - 11:00 PM
Thursday: 8:00 AM - 11:00 PM
Friday: 8:00 AM - 11:00 PM
Saturday: 8:00 AM - 11:00 PM
Sunday: 8:00 AM - 11:00 PM

Outside these hours the forum should lock automatically.

It is practically impossible to close this manually every day. We have an extremely busy forum and on our forum every message must be read and answered. Our ages vary greatly and some users are online 24/24. This is the only solution to give the entire team a bit of peace
Last edited by Mick on Sat Aug 17, 2024 7:02 am, edited 2 times in total.
Reason: Solved.
User avatar
warmweer
Jr. Extension Validator
Posts: 11878
Joined: Fri Jul 04, 2003 6:34 am
Location: somewhere in the space-time continuum

Re: Forum opening hours

Post by warmweer »

Should be feasible with a cron job but I'm not sure how (calling Disable board should be simple, as should be re-enabling it, I think).
But disabled implies that the only Admins and Moderators will be able to see the contents. Other users will just see the index with a "The board is disabled " (or something similar).

I've got a faint memory of having seen a host configuration possibility somewhere: allowing viewing a website at specified times only.

The feature as such seems interesting enough to be a default feature (perhaps the feature has been requested in the past)
Spelling is freeware, which means you can use it for free.
On the other hand, it is not open source, which means you cannot change it or publish it in a modified form.


Time flies like an arrow, but fruit flies like a banana.
User avatar
bennybernaer
Registered User
Posts: 714
Joined: Tue Mar 22, 2011 9:53 pm

Re: Forum opening hours

Post by bennybernaer »

warmweer wrote: Thu Aug 15, 2024 10:20 am Should be feasible with a cron job but I'm not sure how (calling Disable board should be simple, as should be re-enabling it, I think.
But disabled implies that the only Admins and Moderators will be able to see the contents. Other users will just see the index with a "The board is disabled " (or something similar).

I've got a faint memory of having seen a host configuration possibility somewhere: allowing viewing a website at specified times only.
I would then adjust the text with "We are currently closed".

administrators and moderarots is no problem. They can now also be added if you disable the forum.


The nicest and nicest thing would also be a pop-up about the index (when disabled) with the opening hours etc., but this might make it much more complicated.

If you can make disabling the forum automatically (as it already is via acp) then it is actually what I am looking for.

Never seen that this could possibly be done via the host. The forum must remain visible at all times.
User avatar
danieltj
Infrastructure Team Member
Infrastructure Team Member
Posts: 633
Joined: Thu May 03, 2018 9:32 pm
Location: United Kingdom
Name: Daniel James

Re: Forum opening hours

Post by danieltj »

So are you saying that the disable board feature from the ACP is an acceptable solution IF it was automatic in opening and closing the forum? Or would you want the forum to close in a different way?
User avatar
bennybernaer
Registered User
Posts: 714
Joined: Tue Mar 22, 2011 9:53 pm

Re: Forum opening hours

Post by bennybernaer »

danieltj wrote: Thu Aug 15, 2024 10:39 am So are you saying that the disable board feature from the ACP is an acceptable solution IF it was automatic in opening and closing the forum? Or would you want the forum to close in a different way?
The way it is now via ACP, but automatically, is perfect.
Switch on every day at 8:00 am and close again at 11:00 pm.
I can place the opening hours perfectly in the footer.
User avatar
ssl
Registered User
Posts: 2029
Joined: Sat Feb 08, 2020 2:15 pm
Location: Le Lude, Pays de la Loire - France
Name: Fred Rimbert

Re: Forum opening hours

Post by ssl »

If I understand the request correctly, it is necessary to prohibit user connection, and possibly registration, at certain times of the day. The board must always remain accessible to administrators?
Sorry for my English ... I do my best! :anger_right:

:point_right_tone3: phpBB: 3.3.14 | PHP: 8.3.12
:point_right_tone4: [Kill spam on phpBB] - [Some French translation of extensions]
"Mistress, Mistress someone is bothering me in pm"
User avatar
warmweer
Jr. Extension Validator
Posts: 11878
Joined: Fri Jul 04, 2003 6:34 am
Location: somewhere in the space-time continuum

Re: Forum opening hours

Post by warmweer »

ssl wrote: Thu Aug 15, 2024 12:32 pm If I understand the request correctly, it is necessary to prohibit user connection, and possibly registration, at certain times of the day. The board must always remain accessible to administrators?
I wouldn't go as far as to prohibit user connection: but only allow reading (and perhaps editing personal settings).
Spelling is freeware, which means you can use it for free.
On the other hand, it is not open source, which means you cannot change it or publish it in a modified form.


Time flies like an arrow, but fruit flies like a banana.
User avatar
bennybernaer
Registered User
Posts: 714
Joined: Tue Mar 22, 2011 9:53 pm

Re: Forum opening hours

Post by bennybernaer »

ssl wrote: Thu Aug 15, 2024 12:32 pm If I understand the request correctly, it is necessary to prohibit user connection, and possibly registration, at certain times of the day. The board must always remain accessible to administrators?
If you now disable the forum, only moderators and administrators can access the forum. Registrations are therefore not possible. The default settings are perfect. Now only close automatically at 11:00 PM and open again at 8:00 AM.
User avatar
ssl
Registered User
Posts: 2029
Joined: Sat Feb 08, 2020 2:15 pm
Location: Le Lude, Pays de la Loire - France
Name: Fred Rimbert

Re: Forum opening hours

Post by ssl »

I think it would be in your interest to keep the board read-only during closing hours, so as not to bore your users.
Sorry for my English ... I do my best! :anger_right:

:point_right_tone3: phpBB: 3.3.14 | PHP: 8.3.12
:point_right_tone4: [Kill spam on phpBB] - [Some French translation of extensions]
"Mistress, Mistress someone is bothering me in pm"
User avatar
bennybernaer
Registered User
Posts: 714
Joined: Tue Mar 22, 2011 9:53 pm

Re: Forum opening hours

Post by bennybernaer »

ssl wrote: Thu Aug 15, 2024 2:04 pm I think it would be in your interest to keep the board read-only during closing hours, so as not to bore your users.
Not necessary, I prefer to keep it as simple as possible. I would be very happy if someone has the solution.
User avatar
bennybernaer
Registered User
Posts: 714
Joined: Tue Mar 22, 2011 9:53 pm

Re: Forum opening hours

Post by bennybernaer »

In terms of styling in the footer, I have already achieved it myself. Now for the final function... I actually have no idea about that at all. If this topic ultimately belongs better in custom coding, then move it.

Code: Select all

<div class="openingsuren">
<table>
    <tr><th>Openingsuren:</th></tr>
    <tr>Maandag:<td>8:00uur - 23:00uur<br></td></tr>
    <tr>Dinsdag:<td>8:00uur - 23:00uur<br></td></tr>
    <tr>Woensdag:<td>8:00uur - 23:00uur<br></td></tr>
    <tr>Donderdag:<td>8:00uur - 23:00uur<br></td></tr>
    <tr>Vrijdag:<td>8:00uur - 23:00uur<br></td></tr>
	<tr>Zaterdag:<td>8:00uur - 23:00uur<br></td></tr>
	<tr>Zondag:<td>8:00uur - 23:00uur<br></td></tr>
</table>
</div>

Code: Select all

.openingsuren {
	float: right;
	padding: 5px 10px;
	clear: both;
}
Image
User avatar
danieltj
Infrastructure Team Member
Infrastructure Team Member
Posts: 633
Joined: Thu May 03, 2018 9:32 pm
Location: United Kingdom
Name: Daniel James

Re: Forum opening hours

Post by danieltj »

I had a look at core to see how the disable board function works and it seems a lot of it is handled in the user functions file. Might be worth starting there and seeing what you can find.

S_DISABLE_BOARD is a template that’s set somewhere as well which might help back trace where the board decides if it’s disabled or not.
User avatar
bennybernaer
Registered User
Posts: 714
Joined: Tue Mar 22, 2011 9:53 pm

Re: Forum opening hours

Post by bennybernaer »

danieltj wrote: Thu Aug 15, 2024 6:26 pm I had a look at core to see how the disable board function works and it seems a lot of it is handled in the user functions file. Might be worth starting there and seeing what you can find.

S_DISABLE_BOARD is a template that’s set somewhere as well which might help back trace where the board decides if it’s disabled or not.
The only thing I've found so far is...

functions.php:

Code: Select all

		'S_BOARD_DISABLED'		=> ($config['board_disable']) ? true : false,
User avatar
danieltj
Infrastructure Team Member
Infrastructure Team Member
Posts: 633
Joined: Thu May 03, 2018 9:32 pm
Location: United Kingdom
Name: Daniel James

Re: Forum opening hours

Post by danieltj »

Haha, yeah that's what I meant, sorry I was posting from my phone.

You have this php event you can use to update the template variables: core.page_header_after.

All you need to do is figure out if the user is an admin or not and if they're not, check if it's opening time and if isn't then update the board disabled variable to close the forum. There's also core.page_header which is a php event you can use which is earlier on in the file.

I hope this was at least somewhat helpful!
User avatar
bennybernaer
Registered User
Posts: 714
Joined: Tue Mar 22, 2011 9:53 pm

Re: Forum opening hours

Post by bennybernaer »

I'm sorry but your last message is a bit Chinese to me. In which php file should I look for that event? I don't know at all what code to look for or replace there. I can't write PHP myself.

Return to “phpBB Custom Coding”