by Ange Tuteur November 18th 2015, 3:03 pm
I found a better way to set it up, so replace the script with this :
- Code:
$(function() {
var storage = window.localStorage;
if (_userdata.session_logged_in && storage) {
if (!storage['post_count_' + _userdata.username] || +storage['post_count_' + _userdata.username + '_exp'] < +new Date - 24*60*60*1000) {
storage['post_count_' + _userdata.username] = _userdata.user_posts;
storage['post_count_' + _userdata.username + '_exp'] = +new Date;
}
$('form[name="post"]').submit(function(e) {
var storage = window.localStorage;
if (storage && Math.abs(+storage['post_count_' + _userdata.username] - _userdata.user_posts) > 20) {
alert('You have reached the maximum number of posts for today.');
e.preventDefault();
}
});
}
});
This will add a storage item for a specific user. For example, "User A" has reached the limit and cannot post anymore, but your "User B" account can still post. Logging out will no longer remove the post limit for individual accounts, unless the duration is exceeded, then the post count is reset. You can of course still bypass this with clearing your cache, etc.. but it should be better than before.
is the amount of time until the user's post limit is reset. It is :
( 24 hours, 60 minutes, 60 seconds, 1000 milliseconds )