The forum of the forums
Would you like to react to this message? Create an account in a few clicks or log in to continue.

How to limit number of posts per user a day?

4 posters

Go down

Solved How to limit number of posts per user a day?

Post by th4nhc0n9 October 12th 2014, 2:29 pm

In my forum, users spam alot, I want to limit number of posts of user per 1 days.

E.g: 5 topics /1 day 20 posts/ day per user. Is it possible?
Thanks.
th4nhc0n9
th4nhc0n9
Forumember

Male Posts : 161
Reputation : 3
Language : Vietnam

http://vnbeauties.com

Back to top Go down

Solved Re: How to limit number of posts per user a day?

Post by Base October 12th 2014, 2:33 pm

Hello,

As far as I know, it is not possible to limit how many times a user can post in one day.
Base
Base
Forumaster

Male Posts : 10383
Reputation : 1695
Language : English and French
Location : United Kingdom, England

http://forumotionhub.net

Back to top Go down

Solved Re: How to limit number of posts per user a day?

Post by Ape October 12th 2014, 3:06 pm

Sorry this can not be done.

APE


How to limit number of posts per user a day? Left1212How to limit number of posts per user a day? Center11How to limit number of posts per user a day? Right112
How to limit number of posts per user a day? Ape_b110
How to limit number of posts per user a day? Ape1010
Ape
Ape
Administrator
Administrator

Male Posts : 19449
Reputation : 2011
Language : fluent in dork / mumbojumbo & English haha

http://chatworld.forumotion.co.uk/

Back to top Go down

Solved Re: How to limit number of posts per user a day?

Post by th4nhc0n9 October 12th 2014, 5:01 pm

I hope it is possible to do by js or css. Away, thank for your info.
th4nhc0n9
th4nhc0n9
Forumember

Male Posts : 161
Reputation : 3
Language : Vietnam

http://vnbeauties.com

Back to top Go down

Solved Re: How to limit number of posts per user a day?

Post by Ange Tuteur October 12th 2014, 5:50 pm

Hello,

Yes, it's possible by JavaScript, but it can be bypassed if you disable it. Try this :
Administration Panel > Modules > JavaScript codes management > Create a new script

Title : Your choice
Placement : In all the pages
Paste the code below :
Code:
$(function() {
  var perDay = 20,
  errorMsg = 'You\'ve reached the maximum number of posts per day.';
  
  if (localStorage.postExp > +new Date - 24*60*60*1000 && Math.abs(localStorage.postsThen - _userdata.user_posts) >= perDay) $('form[action="/post"] input[type="submit"]').click(function() {alert(errorMsg); return false});
  else if (localStorage.postExp === undefined) {
    localStorage.postsThen = _userdata.user_posts;
    localStorage.postExp = +new Date;
  }
})

At the top are two variables you can modify :
perDay : The amount of posts a user can post a day. ( counted from the time they visit the forum )
errorMsg : The message displayed when they try to post, but have reached the limit.

Just to let you know, this can be bypassed if :
* Member is using an outdated browser
* Member disabled JavaScript
* Member has cleared their browser cache
Ange Tuteur
Ange Tuteur
Forumaster

Male Posts : 13207
Reputation : 3000
Language : English & 日本語
Location : Pennsylvania

https://fmdesign.forumotion.com

Back to top Go down

Solved Re: How to limit number of posts per user a day?

Post by th4nhc0n9 October 12th 2014, 8:25 pm

It is OK. Thank U very much!
th4nhc0n9
th4nhc0n9
Forumember

Male Posts : 161
Reputation : 3
Language : Vietnam

http://vnbeauties.com

Back to top Go down

Solved Re: How to limit number of posts per user a day?

Post by Ange Tuteur October 12th 2014, 11:28 pm

You're welcome,

I may have made a small mistake in my previous post. However, If you notice anything wrong, try replacing it by this script :
Code:
$(function() {
  var perDay = 20,
  errorMsg = 'You\'ve reached the maximum number of posts per day.';
  
  if (localStorage.postExp > +new Date - 24*60*60*1000 && Math.abs(localStorage.postsThen - _userdata.user_posts) >= perDay) $('form[action="/post"] input[type="submit"]').click(function() {alert(errorMsg); return false});
  else if (localStorage.postExp === undefined && _userdata.session_logged_in === 1) {
    localStorage.postsThen = _userdata.user_posts;
    localStorage.postExp = +new Date;
  }
})

Topic archived

If you have any trouble feel free to open a new topic. Smile
Ange Tuteur
Ange Tuteur
Forumaster

Male Posts : 13207
Reputation : 3000
Language : English & 日本語
Location : Pennsylvania

https://fmdesign.forumotion.com

Back to top Go down

Back to top


 
Permissions in this forum:
You cannot reply to topics in this forum