inherit
167122
0
Jan 27, 2021 13:41:15 GMT -8
NWRP Staff
54
May 2011
kkira
|
Post by NWRP Staff on Jul 9, 2020 17:59:38 GMT -8
Is there any way, code or plugin or anything, to make it where members can only post in a certain thread during specific times of day? I have the live clock plugin if that could be used to do this?
Thanks for any help!
|
|
inherit
252032
0
Apr 26, 2024 23:51:41 GMT -8
Retread
Tribbial Pursuit.
5,017
January 2018
retread
|
Post by Retread on Jul 10, 2020 5:46:29 GMT -8
Hi NWRP Staff I don't think that will be possible in a way that doesn't have loopholes. I'm sure a proficient coder could use javascript in a free-standing script or plugin to make changes in what's displayed on a page, having time (either universal time or the user's local time) as part of the conditional. But the way to properly inhibit posting on a specific thread would be to lock it. That's an administrative action. I don't think JS can do that. JS can be used to hide or display the buttons associated with replying and quoting on a thread. But that creates two loopholes. 1 - Scripts and plugins don't function in the Mobile version of ProBoards. So anyone using Mobile view would be able to reply or quote at any time of the day or night. This loophole could be closed by disabling Mobile view (Admin Home> Upgrades> Experiments). That could be very inconvenient for users on phones and other small screens who would be forced to use desktop version. 2 - Even with Mobile view disabled, a savvy forum user can still reply to a thread (or quote a post in a thread) without a button, by manipulating what's in the address bar. For instance, placing this in their address bar will allow them to initiate a reply to the thread we're currently in: support.proboards.com/post/new/663056
|
|
inherit
167122
0
Jan 27, 2021 13:41:15 GMT -8
NWRP Staff
54
May 2011
kkira
|
Post by NWRP Staff on Jul 10, 2020 10:09:37 GMT -8
Hmm good to know.
The first loophole concerns me more than the second.
Either way, could you tell me how to hide the buttons for replying/quoting based on universal forum time? I appreciate the help as always.
|
|
inherit
252032
0
Apr 26, 2024 23:51:41 GMT -8
Retread
Tribbial Pursuit.
5,017
January 2018
retread
|
Post by Retread on Jul 10, 2020 10:40:15 GMT -8
Either way, could you tell me how to hide the buttons for replying/quoting based on universal forum time? Me personally, no. I understand the basic principles and that would include using the JavaScript getUTCHours() method, determining if that was within a minimum and maximum value, and anding that with the route being thread, as well as the ThreadID being equal to the ID of the thread in question before the function would be performed (setting the css of the targeted elements to display:none; But I'm not proficient in writing JavaScript. There are other members of the Support Forum who are.
|
|
inherit
Official Code Helper
65613
0
1
Oct 22, 2024 1:56:19 GMT -8
Chris
"'Oops' is the sound we make when we improve"
9,018
December 2005
horace
RedBassett's Mini-Profile
|
Post by Chris on Jul 16, 2020 23:55:45 GMT -8
Is there any way, code or plugin or anything, to make it where members can only post in a certain thread during specific times of day? I have the live clock plugin if that could be used to do this? Thanks for any help! The lack of specificity coupled with the inherent weaknesses of client side scripting for this task pretty much makes this a request to be likely passed over for a requests with more details and a task more suited for scripting. It might help if you added details such as the actual times you wanted to allow posting, whether it is to be based on their local device time or some centralized time, a link to the forum or a similar forum this intended for so it can be inspected for anomalies such as weird theme templates which could drastically change the way a code gets written. With the caveats Retread mentioned there is a plugin that might be able do the job and that would be the Condition X plugin. You could use it to insert a message for the thread in question then have it run a script to destroy the functionality of the posting form (quick and full) so posts cannot be created during the requested times. - In plugin configuration on the "What" tab add the following to the header
<div class="container locked_thread"> <div class="title-bar" style="background-color: rgb(230, 33, 25);"> <h2>Locked Topic Notice!</h2> </div> <div class="content" style="padding: 10px;"> This topic only accepts posts between 9AM and 5PM! </div> <form id="time-locked"></form> </div> *Feel free to change the wording or structure but leave the form intact
Then on the "Advanced" tab add the following 4 lines
pb.data('page').thread && pb.data('page').thread.id == 6 (new Date()).getHours()>=17 || (new Date()).getHours()<=9 $(x=>$('.form_post_quick_reply textarea[name=message],.wysiwyg-textarea').attr({id:'form_time-locked',form:'time-locked'}).removeAttr('name')) !== NaN $(document).on('wysiwygcreate',x=>{$('.wysiwyg-textarea').attr({id:'form_time-locked',form:'time-locked'}).removeAttr('name')}) !== NaN
*- The first line tests for correct thread, the id of the thread used in the example was 6, your mileage may vary
- The second line tests for time (on users computer, which could be manually changed to get around the restriction). The times used is an arbitrary 9am to 5pm in the user's timezone (no details given). So user1 could post at 10am since his computer's timezone says it is 10am where he is at while user2 at that very same time would be unable to post since the timezone on his computer said 6am where he is at. A centralized timezone would let everybody go by one specific time and remove the temptation of changing their computer clock to easily get around the restriction (eg (new Date(pb.data('serverDate')).getUTCHours())
The third a fourth lines disables the quick reply and full reply forms respectively, this is all contingent of course on whether the user is allowing javascript to be executed in their browser
|
|
inherit
167122
0
Jan 27, 2021 13:41:15 GMT -8
NWRP Staff
54
May 2011
kkira
|
Post by NWRP Staff on Jul 17, 2020 9:11:06 GMT -8
Oh wow, I had forgot about this -- thank you Chris ! I do have Condition X and these instructions seem fairly straight forward. Not sure if I'll be using it right away due to the issues discussed earlier, especially with mobile, but it is nice to have this just in case. Just to be clear, if you wanted it to run on a centralized timezone where in the code would you put this new line you provided? (new Date(pb.data('serverDate')).getUTCHours()
|
|
inherit
Official Code Helper
65613
0
1
Oct 22, 2024 1:56:19 GMT -8
Chris
"'Oops' is the sound we make when we improve"
9,018
December 2005
horace
RedBassett's Mini-Profile
|
Post by Chris on Jul 17, 2020 22:51:39 GMT -8
On the advanced tab coding replace the highlighted coding
An empty Date() such as the ones used above pulls the date from the user's computer. If we supply it with the proboards server date instead then if user's computer time is "wrong" that won't make a difference. getHours() will adjust the hour to the timezone set on the user's computer while getUTCHours() means everybody must go by Greenwich(UTC) time.
|
|