Like SystemiConnectFri 15 Oct 2021, 04:50
Auto Save MessagesLGforumFri 26 Feb 2021, 13:31
New tutorial questionTheCrowMon 15 Feb 2021, 08:12
Support iOS Emojis (and other platforms)LGforumSun 14 Feb 2021, 01:25
LGforum (2806)
Make Chat only available to a certain users Vote_lcapMake Chat only available to a certain users Voting_barMake Chat only available to a certain users Vote_rcap 
Mr.Easybb (1587)
Make Chat only available to a certain users Vote_lcapMake Chat only available to a certain users Voting_barMake Chat only available to a certain users Vote_rcap 
Bloodbath (745)
Make Chat only available to a certain users Vote_lcapMake Chat only available to a certain users Voting_barMake Chat only available to a certain users Vote_rcap 
Rukiafan (533)
Make Chat only available to a certain users Vote_lcapMake Chat only available to a certain users Voting_barMake Chat only available to a certain users Vote_rcap 
Dom (513)
Make Chat only available to a certain users Vote_lcapMake Chat only available to a certain users Voting_barMake Chat only available to a certain users Vote_rcap 
puppycheese (446)
Make Chat only available to a certain users Vote_lcapMake Chat only available to a certain users Voting_barMake Chat only available to a certain users Vote_rcap 
pedro (330)
Make Chat only available to a certain users Vote_lcapMake Chat only available to a certain users Voting_barMake Chat only available to a certain users Vote_rcap 
Neymar (301)
Make Chat only available to a certain users Vote_lcapMake Chat only available to a certain users Voting_barMake Chat only available to a certain users Vote_rcap 
Hitsu (281)
Make Chat only available to a certain users Vote_lcapMake Chat only available to a certain users Voting_barMake Chat only available to a certain users Vote_rcap 
Flora (275)
Make Chat only available to a certain users Vote_lcapMake Chat only available to a certain users Voting_barMake Chat only available to a certain users Vote_rcap 


Make Chat only available to a certain users

bicky1980bicky1980
Status : No status yet...

Posts : 14
Join date : 2013-03-09
Mon 18 Mar 2013, 20:36
Hi guys

Now I have the chat feature working, I wonder if I could only enable chat to certain users - this would be useful for just admins or just me, as I only open the chat during certain times.

I want to be able to test the different options, without the users seeing anything which is happening 'behind the scenes'

Any help is this would be great

Thanks Smile
LGforumLGforum
Status : Working to restore AWC!

Posts : 2806
Join date : 2011-10-05
Age : 30
Location : UK
Tue 19 Mar 2013, 09:11
You could prevent them logging in easily by adding this plug in:
Code:
avacweb_chat_config.add_event('onlogin', function(e) {
    if(avacweb_chat.user('id') !== 1) {
        e.preventDefault();
        avacweb_chat.popup('Sorry, the chatbox is in available at the moment.');
    }
});
This would make the chatbox only available to user 1. Simply remove it or comment it out to allow everyone back in.

Alternatively, you can prevent them from evening opening the box by changing it from an 'onlogin' event to an 'onopen' event.
bicky1980bicky1980
Status : No status yet...

Posts : 14
Join date : 2013-03-09
Tue 19 Mar 2013, 21:43
Thanks for this, however when I add this code under the installation code for Avacweb chat this just seems to stop the chat button from working - even when I have put the ID to my user ID.
LGforumLGforum
Status : Working to restore AWC!

Posts : 2806
Join date : 2011-10-05
Age : 30
Location : UK
Tue 19 Mar 2013, 23:14
Show me the exact code you put please. I wrote this on my phone but I don't see any mistake in it.
bicky1980bicky1980
Status : No status yet...

Posts : 14
Join date : 2013-03-09
Wed 20 Mar 2013, 00:14
Including the installation code as well its as follows:

Code:
var avacweb_chat_config = {
          version : '1-7',
          new_chat_title : 'Live Chat',
          light_up_color : 'orange',
          auto_log_in : 'open',
          archives : 1,
          sound_file : 'http://www.freesfx.co.uk/rx2/mp3s/2/1305_1256857800.mp3',
          stylesheet : 'http://chat.avacweb.net/avacweb_chat.css',
          disable_timeout : 1,
          allow_private_messaging : 1,
          allow_user_resize : 1,
          message_hook : [],
          user_hook : [],
          commands : {},
          events : {},
          add_event : function(type, fn) {
              type = /^on/.test(type) ? type : 'on' + type;
              type in this.events ? this.events[type].push(fn) : this.events[type] = [fn];

          }
        };
        document.write('<script type="text/javascript" src="http://chat.avacweb.net/v' + avacweb_chat_config.version + '.js" id="achat_script"></script>');

        avacweb_chat_config.add_event('onlogin', function(e) {
            if(avacweb_chat.user('id') !== 152) {
                e.preventDefault();
                avacweb_chat.popup('Sorry, the chatbox is in available at the moment.');
            }
        });
LGforumLGforum
Status : Working to restore AWC!

Posts : 2806
Join date : 2011-10-05
Age : 30
Location : UK
Thu 21 Mar 2013, 15:16
Are you sure your user ID is 152? Its usually 1, or something low for the admin.
bicky1980bicky1980
Status : No status yet...

Posts : 14
Join date : 2013-03-09
Thu 21 Mar 2013, 23:05
Yes I am certain this is my userID (I was added to the admin team)
DomDom
Status : No status yet...

Posts : 513
Join date : 2011-12-24
Location : USA
Fri 22 Mar 2013, 00:37
Shouldn't it be == if you're testing it for yourself then? Rather than !== ?
avatargreat alexander x
Status : No status yet...

Posts : 5
Join date : 2013-03-21
Age : 30
Location : Cyprus
Fri 22 Mar 2013, 06:21
Ηello there. I have a forum as well and i would like to have a code if possible so only the team of the forum can log in. How can i make this?
bicky1980bicky1980
Status : No status yet...

Posts : 14
Join date : 2013-03-09
Fri 22 Mar 2013, 22:40
I think the code is supposed to display the error message if the user if not equal to me - which is the correct action I want. However it still doesn't work Sad
Mr.EasybbMr.Easybb
Status : Love this site, that's why I'm back each day again... lol Samantha's co-owner now. Well deserved!

Posts : 1587
Join date : 2013-01-04
Sat 23 Mar 2013, 04:39
Rideem is correct I believe !== makes the question at hand false == is for true no?
LGforumLGforum
Status : Working to restore AWC!

Posts : 2806
Join date : 2011-10-05
Age : 30
Location : UK
Sat 23 Mar 2013, 10:20
No. It should be !==
How come you two, who understand JavaScript think that, yet the OP sees it correctly. Razz
The if statement says 'if the user is not user 152 then don't log them in and display the message' - aka blocking everyone but user 152.

Have you checked your error console, for potential issues in other javascripts?
If so and there are none, can you provide me a test account or something to look.
ShadowShadow
Status : No status yet...

Posts : 232
Join date : 2011-11-09
Location : Serbia
Sat 23 Mar 2013, 11:12
Lg is it possible to make for groups ?
bicky1980bicky1980
Status : No status yet...

Posts : 14
Join date : 2013-03-09
Sat 23 Mar 2013, 13:17
test account details sent via PM...Thanks in advance
LGforumLGforum
Status : Working to restore AWC!

Posts : 2806
Join date : 2011-10-05
Age : 30
Location : UK
Sun 24 Mar 2013, 01:27
Thanks. Might not be until tomorrow or Monday when I get to look though. Working all day Sunday.
Mr.EasybbMr.Easybb
Status : Love this site, that's why I'm back each day again... lol Samantha's co-owner now. Well deserved!

Posts : 1587
Join date : 2013-01-04
Sun 24 Mar 2013, 05:02
Lol at Post 12 Read it all wrong I suppose. When I said:

!== makes the question at hand false (Meaning if the user is not 152 e.preventDefault)
and == makes the question if it is 152. I guess you misunderstood me Wink

Though I guess I took what the OP said wrong as well. Anyways glad to see you back LG. I have a few codes that you may be interested in Wink
avatargreat alexander x
Status : No status yet...

Posts : 5
Join date : 2013-03-21
Age : 30
Location : Cyprus
Mon 25 Mar 2013, 09:50
It means that if the user that logs in is not user 152 then the code will automatically show the message that "You are not allowed to the chat-room"! That' s what i understood..

But can i have the code for this chat for forum version phpBB2 please?
LGforumLGforum
Status : Working to restore AWC!

Posts : 2806
Join date : 2011-10-05
Age : 30
Location : UK
Mon 25 Mar 2013, 11:26
It's the same for all forum versions. Most AWC codes are. When I get on a computer I'll use the test account provided by the OP, to find out why It isn't working. If anyone else tries it, and it is working fine, let me know, as that mean the issue is only with OP's forum.

To the author, have you checked your error console? As other javascripts are most likely the issue. I'll be a bit annoyed if I waste my time and find 20 odd errors on your forum, as that would clearly be the issue.
ShadowShadow
Status : No status yet...

Posts : 232
Join date : 2011-11-09
Location : Serbia
Mon 25 Mar 2013, 11:30
Lg could you please answer on my question ? Smile
DomDom
Status : No status yet...

Posts : 513
Join date : 2011-12-24
Location : USA
Tue 26 Mar 2013, 00:28
LGforum wrote:[quotelink="http://www.avacweb.com/t1115-make-chat-only-available-to-a-certain-users#10894"]No. It should be !==
How come you two, who understand JavaScript think that, yet the OP sees it correctly. Razz
The if statement says 'if the user is not user 152 then don't log them in and display the message' - aka blocking everyone but user 152.

Have you checked your error console, for potential issues in other javascripts?
If so and there are none, can you provide me a test account or something to look.
I thought he was testing it himself by making it not appear for himself. Wink
Sponsored content