Chatbox access by post count
2 posters
Page 1 of 1
Chatbox access by post count
Hello
Please understand I've spent days on this forum looking
for similar topics with working solutions.
I did find the following main topics:
https://help.forumotion.com/t137827-request-certain-post-count-before-accessing-the-chatbox
This started off fairly promising.
"Looking for a code or a system to implement on my forun to make it so new members have to have a post count of 5 to access the chatbox."
"That the chatbox is visible, but can only post if you have the minimum amount of posts. "
That's all I wanted, except 30 posts instead of 5.
Then it goes on to say:
"You can only post messages When You have more than 5 threads started!"
But I don't want threads started, I just want simple posts, replies to existing topics.
THEN it goes further saying:
"from all members with an account that was older then 5 days and in order to see that chat box you had to make at least 1 post in a 24h period also with safe list to add some admins or like people who work on the site but don't post"
Wait.. what? WHY? Why "an account that was older then 5 days"
and why "you had to make at least 1 post in a 24h period" ?
That is NOT what the topic was supposed to be about.
"so these settings above would set it to require 2 post every 5 days if the joindate was longer then 10 days ago .. also user 3,876,232,1221,9764 will not be effected by this script"
Nope. Nope. Nuh-uh. Nooooo...
Further on, I already have a group setup for members under 30 posts, so I decided to check this out: https://help.forumotion.com/t137069-controlling-the-chatbox-group-based-access
But then it says "I'm using AWC" which means AvecWeb Chat. I have the default Forumotion chatbox, not AWC
I'm fairly sure this uses script for the same AWC
https://help.forumotion.com/t138130-post-requirement-to-use-chatbox-filter-by-usergroups
I tried some variations and neither of it worked.
Like this one:
Also, for full disclosure, I use several other customization scripts to my chatbox
particularly, I included the autologin, the archives in new tab,
the chatbox in toolbar and the round buttons.
I only enabled autologin today, but unless I can make it an option for people to turn on and off, I think I'll disable it.
This is the full current script (with some CSS modifications as well though)
Please, help me out. Members with 0 posts have recently been causing problems.
I don't care if newbies can access the /chatbox link directly to log in, most of them don't even know that exists. I just don't want them to be able to post on the main page (or toolbar chatbox) unless they have made 30 posts.
Please understand I've spent days on this forum looking
for similar topics with working solutions.
I did find the following main topics:
https://help.forumotion.com/t137827-request-certain-post-count-before-accessing-the-chatbox
This started off fairly promising.
"Looking for a code or a system to implement on my forun to make it so new members have to have a post count of 5 to access the chatbox."
"That the chatbox is visible, but can only post if you have the minimum amount of posts. "
That's all I wanted, except 30 posts instead of 5.
Then it goes on to say:
"You can only post messages When You have more than 5 threads started!"
But I don't want threads started, I just want simple posts, replies to existing topics.
THEN it goes further saying:
"from all members with an account that was older then 5 days and in order to see that chat box you had to make at least 1 post in a 24h period also with safe list to add some admins or like people who work on the site but don't post"
Wait.. what? WHY? Why "an account that was older then 5 days"
and why "you had to make at least 1 post in a 24h period" ?
That is NOT what the topic was supposed to be about.
"so these settings above would set it to require 2 post every 5 days if the joindate was longer then 10 days ago .. also user 3,876,232,1221,9764 will not be effected by this script"
Nope. Nope. Nuh-uh. Nooooo...
Further on, I already have a group setup for members under 30 posts, so I decided to check this out: https://help.forumotion.com/t137069-controlling-the-chatbox-group-based-access
But then it says "I'm using AWC" which means AvecWeb Chat. I have the default Forumotion chatbox, not AWC
I'm fairly sure this uses script for the same AWC
https://help.forumotion.com/t138130-post-requirement-to-use-chatbox-filter-by-usergroups
I tried some variations and neither of it worked.
Like this one:
- Code:
$(function() {
if (_userdata.user_posts >= 30) {
- Code:
$(function() {
var ac = document.getElementById('avacweb_chat_button');
ac.style.display = 'none';
if (_userdata.user_posts >= 100) ac.style.display = '';
else ac.parentNode.removeChild(ac);
});
Also, for full disclosure, I use several other customization scripts to my chatbox
particularly, I included the autologin, the archives in new tab,
the chatbox in toolbar and the round buttons.
I only enabled autologin today, but unless I can make it an option for people to turn on and off, I think I'll disable it.
This is the full current script (with some CSS modifications as well though)
- Code:
(function() {
if (!window.FA) window.FA = {};
if (FA.Chat) {
if (window.console) console.warn('FA.Chat has already been initialized');
return;
}
FA.Chat = {
// chatbox settings
config : {
height : '60%',
width : '70%',
live_notif : true,
sound_notif : {
enabled : true,
file : 'https://ia601507.us.archive.org/3/items/wooshsfx/wooshsfx.mp3'
},
notifRate : 10000
},
// language settings
lang : {
chatbox : 'Chatbox',
new_msg : 'A new message has been posted in the <a href="javascript:FA.Chat.toggle();">chatbox</a>.'
},
// technical data below
node : {}, // node cache
users : 0, // users in chat
messages : 'initial', // total chat messages
actif : false, // tells us if the chatbox is opened
notifActif : false, // tells us if the notifications are active
// initial setup of the chatbox
init : function() {
var right = document.getElementById('fa_right'),
container = document.createElement('DIV'),
button = document.createElement('A'),
audio;
button.id = 'fa_chat_button';
button.innerHTML = FA.Chat.lang.chatbox + ' <span id="fa_chatters">(0)</span>';
button.onclick = FA.Chat.toggle;
FA.Chat.node.button = button;
container.id = 'fa_chat_container';
container.innerHTML = '<iframe id="fa_chat" src="/chatbox"></iframe>';
container.style.width = FA.Chat.config.width;
container.style.height = FA.Chat.config.height;
container.style.bottom = '-' + FA.Chat.config.height;
container.style.visibility = 'hidden';
if (right) {
right.insertBefore(button, right.lastChild); // add the chat button to the right side of the toolbar
document.body.appendChild(container);
// create the notification audio element
if (FA.Chat.config.sound_notif.enabled) {
audio = document.createElement('AUDIO');
audio.src = FA.Chat.config.sound_notif.file;
if (audio.canPlayType) {
FA.Chat.node.audio = audio;
document.body.appendChild(audio);
}
}
FA.Chat.node.container = document.getElementById('fa_chat_container');
FA.Chat.node.chatters = document.getElementById('fa_chatters');
FA.Chat.node.frame = document.getElementById('fa_chat');
FA.Chat.node.frame.onload = FA.Chat.getFrame;
}
delete FA.Chat.init;
},
// get the frame window, document, and elements
getFrame : function() {
if (FA.Chat.poll) window.clearInterval(FA.Chat.poll);
if (this.contentDocument || this.contentWindow) {
FA.Chat.window = this.contentWindow;
FA.Chat.document = this.contentDocument ? this.contentDocument : FA.Chat.window.document;
FA.Chat.node.message = FA.Chat.document.getElementById('message');
FA.Chat.node.members = FA.Chat.document.getElementById('chatbox_members');
FA.Chat.poll = window.setInterval(FA.Chat.listen, 300); // listen for changes every 0.3 seconds
}
},
// listen for changes in the chatbox
listen : function() {
var users = FA.Chat.node.members.getElementsByTagName('LI').length,
messages = FA.Chat.window.chatbox.messages.length;
// update user count
if (users > FA.Chat.users || users < FA.Chat.users) {
FA.Chat.users = users;
FA.Chat.node.chatters.innerHTML = '(' + FA.Chat.users + ')';
}
// initial / active updates
if ((FA.Chat.messages == 'initial' && messages) || FA.Chat.notifActif || FA.Chat.actif) FA.Chat.messages = messages;
// notify new messages while connected and the chatbox is closed
if (!FA.Chat.actif && !FA.Chat.notifActif && FA.Chat.window.chatbox.connected && (messages > FA.Chat.messages || messages < FA.Chat.messages)) {
FA.Chat.messages = messages; // update message count
FA.Chat.notifActif = true;
if (FA.Chat.config.live_notif) FA.Chat.notify(FA.Chat.lang.new_msg); // show live notification
if (FA.Chat.config.sound_notif.enabled && FA.Chat.node.audio) FA.Chat.node.audio.play(); // play sound notification
// wait before notifying the user again
window.setTimeout(function() {
FA.Chat.notifActif = false;
}, FA.Chat.config.notifRate);
}
},
// create a custom notification
notify : function(msg) {
var notif = document.createElement('DIV'),
live = document.getElementById(Toolbar.LIVE_NOTIF);
notif.className = 'fa_notification';
notif.innerHTML = '<div class="content ellipsis">' + msg + '</div>';
notif.style.display = 'none';
$(notif).mouseover(function() { $(this).stop(true, true) });
$(notif).mouseleave(function() { $(this).delay(5000).fadeOut() });
live.insertBefore(notif, live.firstChild);
$(notif.firstChild).dotdotdot();
$(notif).fadeIn(100, function() { $(this).delay(10000).fadeOut() });
},
// toggle the display state of the chatbox
toggle : function() {
var container = FA.Chat.node.container.style;
if (/hidden/i.test(container.visibility)) {
FA.Chat.node.button.className = 'fa_chat_active';
FA.Chat.actif = true;
container.visibility = 'visible';
container.bottom = '3px';
// auto focus the message field
window.setTimeout(function() {
FA.Chat.node.message.focus();
}, 350); // some browsers ( firefox ) need a delay
} else {
FA.Chat.node.button.className = '';
FA.Chat.actif = false;
container.visibility = 'hidden';
container.bottom = '-' + FA.Chat.config.height;
}
}
};
$(function(){
// initialize the chat when the document is ready and the user is logged in
if (_userdata.session_logged_in) $(FA.Chat.init);
});
})();
$(window).load(function() {
var chatbox_script = function() {
setTimeout(function(){ $('#chatbox_option_co:visible').click() }, 1000);
};
var s=document.createElement('script');s.text="("+chatbox_script.toString()+")();";$('object[data^="/chatbox/index.forum"],iframe[src^="/chatbox/index.forum"]').each(function(){try{$(this.contentDocument||this.contentWindow.document).find("#chatbox").closest("html").find("head").first().each(function(){this.appendChild(s.cloneNode(true))})}catch(a){}})
});
$(window).load(function() {
var chatbox_script = function() {
$("#chatbox_option_with_archives a").attr('target', 'ChatBox');
};
var s=document.createElement('script');s.text="("+chatbox_script.toString()+")();";$('object[data^="/chatbox/index.forum"],iframe[src^="/chatbox/index.forum"]').each(function(){try{$(this.contentDocument||this.contentWindow.document).find("#chatbox").closest("html").find("head").first().each(function(){this.appendChild(s.cloneNode(true))})}catch(a){}})
});
Please, help me out. Members with 0 posts have recently been causing problems.
I don't care if newbies can access the /chatbox link directly to log in, most of them don't even know that exists. I just don't want them to be able to post on the main page (or toolbar chatbox) unless they have made 30 posts.
Last edited by DVAted on November 2nd 2015, 8:58 am; edited 1 time in total
Re: Chatbox access by post count
Hi @DVAted,
If you only want to display the toolbar chatbox for those with a specific post count find the following condition :
and replace it by :
and for the other scripts which start with :
You can replace them with this :
If you only want to display the toolbar chatbox for those with a specific post count find the following condition :
- Code:
if (_userdata.session_logged_in) $(FA.Chat.init);
and replace it by :
- Code:
if (_userdata.session_logged_in && _userdata.user_posts >= 30) $(FA.Chat.init);
and for the other scripts which start with :
- Code:
$(window).load(function() {
You can replace them with this :
- Code:
$(window).load(function() {
if (_userdata.user_posts < 30) return;
Re: Chatbox access by post count
oh thank you for replying on a Sunday evening, Ange, I really appreciate it.
The little tricks you made worked, the users with no posts or below 30 no longer have the chatbox in the toolbar.
However, they still have the chatbox on the front (home) page on top. This is from my HTML of Display/General/Template "body_index" Home Page code
also, I've forgotten to mention I included a rules link under the chatbox as well:
again, thank you
The little tricks you made worked, the users with no posts or below 30 no longer have the chatbox in the toolbar.
However, they still have the chatbox on the front (home) page on top. This is from my HTML of Display/General/Template "body_index" Home Page code
- Code:
<!-- BEGIN switch_chatbox_activate -->
<tr>
<td class="row1">
<span class="gensmall">{TOTAL_CHATTERS_ONLINE} : {CHATTERS_LIST}<br />
<!-- BEGIN switch_chatbox_popup -->
<div id="chatbox_popup"></div>
<script type="text/javascript">
//<![CDATA[
insertChatBoxPopup('{disable_viewonline.switch_chatbox_activate.switch_chatbox_popup.U_FRAME_CHATBOX}', '{L_CLICK_TO_JOIN_CHAT}');
//]]>
</script>
<!-- END switch_chatbox_popup -->
</span>
</td>
</tr>
<!-- END switch_chatbox_activate -->
also, I've forgotten to mention I included a rules link under the chatbox as well:
- Code:
{CHATBOX_TOP}
<!-- BEGIN switch_user_logged_in -->
<div align="center" class="chatRules"><a href="/t8055-chatbox-rules" target="_blank">CHATBOX RULES</a></div>
<!-- END switch_user_logged_in -->
again, thank you
Last edited by DVAted on November 2nd 2015, 8:18 am; edited 1 time in total
Re: Chatbox access by post count
No problem. ^^ We should be able to use some JavaScript to hide both these elements until they reach the specified amount of posts.
Try replacing the stats part of the template with this :
and replace the chatbox area with this :
Try replacing the stats part of the template with this :
- Code:
<!-- BEGIN switch_chatbox_activate -->
<tr style="display:none;" id="stats_chat_row">
<td class="row1">
<span class="gensmall">{TOTAL_CHATTERS_ONLINE} : {CHATTERS_LIST}<br />
<!-- BEGIN switch_chatbox_popup -->
<div id="chatbox_popup"></div>
<script type="text/javascript">
//<![CDATA[
insertChatBoxPopup('{disable_viewonline.switch_chatbox_activate.switch_chatbox_popup.U_FRAME_CHATBOX}', '{L_CLICK_TO_JOIN_CHAT}');
if (_userdata.user_posts >= 30) {
document.getElementById('stats_chat_row').style.display = '';
}
//]]>
</script>
<!-- END switch_chatbox_popup -->
</span>
</td>
</tr>
<!-- END switch_chatbox_activate -->
and replace the chatbox area with this :
- Code:
<div id="chatbox_top_div" style="display:none;">
{CHATBOX_TOP}
<!-- BEGIN switch_user_logged_in -->
<div align="center" class="chatRules"><a href="/t8055-chatbox-rules" target="_blank">CHATBOX RULES</a></div>
<!-- END switch_user_logged_in -->
</div>
<script type="text/javascript">//<![CDATA[
if (_userdata.user_posts >= 30) {
document.getElementById('chatbox_top_div').style.display = '';
}
//]]></script>
Re: Chatbox access by post count
Thank you! It worked exactly as you said
You are the grand pharaoh of scripting
Much appreciation and respect!
You are the grand pharaoh of scripting
Much appreciation and respect!
Similar topics
» Request Certain Post Count Before Accessing The Chatbox
» How do I make a forum area not count towards post count..?
» Post count stopping at 8000 - Unable to post anymore.
» Post Count
» Post count
» How do I make a forum area not count towards post count..?
» Post count stopping at 8000 - Unable to post anymore.
» Post Count
» Post count
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum