LGforum (2803)
tips - Chatbox auto logging in Vote_lcaptips - Chatbox auto logging in Voting_bartips - Chatbox auto logging in Vote_rcap 
Mr.Easybb (1586)
tips - Chatbox auto logging in Vote_lcaptips - Chatbox auto logging in Voting_bartips - Chatbox auto logging in Vote_rcap 
Bloodbath (745)
tips - Chatbox auto logging in Vote_lcaptips - Chatbox auto logging in Voting_bartips - Chatbox auto logging in Vote_rcap 
Rukiafan (533)
tips - Chatbox auto logging in Vote_lcaptips - Chatbox auto logging in Voting_bartips - Chatbox auto logging in Vote_rcap 
Dom (513)
tips - Chatbox auto logging in Vote_lcaptips - Chatbox auto logging in Voting_bartips - Chatbox auto logging in Vote_rcap 
puppycheese (446)
tips - Chatbox auto logging in Vote_lcaptips - Chatbox auto logging in Voting_bartips - Chatbox auto logging in Vote_rcap 
pedro (330)
tips - Chatbox auto logging in Vote_lcaptips - Chatbox auto logging in Voting_bartips - Chatbox auto logging in Vote_rcap 
Neymar (301)
tips - Chatbox auto logging in Vote_lcaptips - Chatbox auto logging in Voting_bartips - Chatbox auto logging in Vote_rcap 
Hitsu (281)
tips - Chatbox auto logging in Vote_lcaptips - Chatbox auto logging in Voting_bartips - Chatbox auto logging in Vote_rcap 
Flora (275)
tips - Chatbox auto logging in Vote_lcaptips - Chatbox auto logging in Voting_bartips - Chatbox auto logging in Vote_rcap 


Chatbox auto logging in

LGforumLGforum
Status : Working to restore AWC!

Posts : 2803
Join date : 2011-10-05
Age : 27
Location : UK
Fri 04 May 2012, 19:11
I found out this quite a while ago but wanted to check a few things before posting about it.

Its a mixture of things, added together can create something quite useful. Let me explain, with the chatbox:
- If you try and send an empty message the form does not send.
- If you send an empty message via ajax, it does not get added to the message list.
- If you are logged out and send a message (empty or not), then you get logged in.

Combining these three things together, if you send an empty message via ajax whilst not logged into the chatbox, you will be logged on. Wink

Now previously, creating an automatic log in to the chatbox was only possible if you could access the function [ic]CB_disconnect()[/ic] which was only in the main '/chatbox' page. Which as you know our Javascripts are not included in. However, with these three points above, I'll show you today that it is now possible to automatically log a user into the chatbox via sending an empty message with ajax Wink
These codes should only be set for 'Homepage only'

This code will log a user into the chatbox: [ic]$.post('/chatbox/chatbox_actions.forum?archives','mode=send&sent=');[/ic] So now, lets get creative with it.

This code will make it so that when the user clicks the 'Chatbox' or 'Join the chat' links in the index page that they will be logged in as the chatbox opens (tested only in phpbb3):
Code:
[panda=js]$(function(){
    var c = document.getElementById('chatbox_popup');
    $(c.previousSibling.previousSibling).add(c).click(function(){
        $.post('/chatbox/chatbox_actions.forum?archives','mode=send&sent=');
    });
});

OR, if you want them to be logged in as soon as they log into your forum:
Code:
[panda=js]$(function(){
 if(document.getElementById('logout')) $.post('/chatbox/chatbox_actions.forum?archives','mode=send&sent=');
});

OR, how about we set a cookie, so we only auto log them in once per session, then the rest is up to them.
Code:
[panda=js]if(my_getcookie('cb_login') != '1') {
  $.post('/chatbox/chatbox_actions.forum?archives','mode=send&sent=');
  my_setcookie('cb_login', '1', false);
}

OR, maybe you want to make your own link which will open the chatbox in a new tab/window and log them in at the same time: [ic]<a href="/chatbox" target="_blank" onclick="$.post('/chatbox/chatbox_actions.forum?archives','mode=send&sent=');">Go to chatbox</a>[/ic]

You can even use this, to get rid of the timeout in the chatbox!
Code:
[panda=js]setInterval(function(){ $.post('/chatbox/chatbox_actions.forum?archives','mode=send&sent='); }, 5000);
This will send that empty message off every 5 seconds, meaning if the user gets logged out, then within 5 seconds at the most he will get logged back in.

And the best bit is, the chatbox pages do not count towards your HTTP Request limit that forumotion has set, because if it did, just chatting to people would make us hit the limit. That's the best bit, this is Ajax that you don't even have to worry about hitting the request limit with.

So there you have it, remember it came from AvacWeb first, auto-logging into the chatbox no matter what your situation is, and even create the effect the time out isn't there!

#tips #AWC
NeymarNeymar
Status : No status yet...

Posts : 301
Join date : 2012-03-11
Location : Glasgow, Scotland
Fri 04 May 2012, 20:21
Fantastic LG! It's probably one of the most requested features for forumotion forums, when reading on the support forum all you see is 'it's not possible', 'that can't be done', log on to Avacweb and there it is. Very Happy

The best thing is, I've read it and actually understand what is happening which is quite nice Smile

I'll give it a try and let you know how it goes.

Thanks!
nutsonlizardsnutsonlizards
Status : No status yet...

Posts : 66
Join date : 2011-11-18
Fri 04 May 2012, 21:03
Awesome thx for sharing Smile
FloraFlora
Status : No status yet...

Posts : 275
Join date : 2011-11-18
Location : USA
Sat 05 May 2012, 06:04
Very nice! Thanks for sharing.
DomDom
Status : No status yet...

Posts : 513
Join date : 2011-12-24
Location : USA
Sun 06 May 2012, 22:21
So many methods Razz
Nice tutorial LG. Wink
Rog360Rog360
Status : No status yet...

Posts : 7
Join date : 2012-06-26
Age : 53
Location : On a mote, Suspended in a sunbeam.
Wed 27 Jun 2012, 18:45
Thanks LGforum for all your work. I got one question for you. Is there a way to make the auto login also show archived chats automatically as well? pirat
LGforumLGforum
Status : Working to restore AWC!

Posts : 2803
Join date : 2011-10-05
Age : 27
Location : UK
Wed 27 Jun 2012, 22:35
Every where in the codes where you see ?archives change to ?archives=1
Rog360Rog360
Status : No status yet...

Posts : 7
Join date : 2012-06-26
Age : 53
Location : On a mote, Suspended in a sunbeam.
Wed 27 Jun 2012, 23:31
Tried changing that and still only auto logs with no archive. Maybe it's because of "onclick="refresh_chatbox('?archives=1');"

Just a guess, as I have no idea about javascript... Smile
avataro0o_mr79
Status : No status yet...

Posts : 6
Join date : 2012-06-29
Fri 29 Jun 2012, 09:23
If i use the chatbox HTML, i have to do?
LGforumLGforum
Status : Working to restore AWC!

Posts : 2803
Join date : 2011-10-05
Age : 27
Location : UK
Fri 29 Jun 2012, 10:06
I don't understand, what chatbox HTML?
avataro0o_mr79
Status : No status yet...

Posts : 6
Join date : 2012-06-29
Fri 29 Jun 2012, 10:22
www.9xstudio.biz/h46-shoutbox

Very Happy.
LGforumLGforum
Status : Working to restore AWC!

Posts : 2803
Join date : 2011-10-05
Age : 27
Location : UK
Fri 29 Jun 2012, 11:10
Yes it would still work.
avatarCalιbuяn
Status : No status yet...

Posts : 3
Join date : 2013-02-08
Fri 08 Feb 2013, 12:49
The cookie part to make them not get logged in every time they visit the homepage isn't working for me...
avatarbeco2326
Status : No status yet...

Posts : 6
Join date : 2013-03-02
Sat 02 Mar 2013, 23:48
where do i put in the code... lol sorry new guy..
LGforumLGforum
Status : Working to restore AWC!

Posts : 2803
Join date : 2011-10-05
Age : 27
Location : UK
Sun 03 Mar 2013, 09:02
If you use AWC, it is an option that you can simply set in the config. Please make sure your reading about the codes you use rather than just copying and pasting and then going.
avatarbeco2326
Status : No status yet...

Posts : 6
Join date : 2013-03-02
Sun 01 Sep 2013, 18:55
i've tried a few couple ways , the stay logged in seems to disconnet then re connect... is there a better way?
avatarbeco2326
Status : No status yet...

Posts : 6
Join date : 2013-03-02
Sun 01 Sep 2013, 19:24
no matter what i do it keeps logging them out and back it Sad
LGforumLGforum
Status : Working to restore AWC!

Posts : 2803
Join date : 2011-10-05
Age : 27
Location : UK
Mon 02 Sep 2013, 00:34
I'm not fully sure what you mean your going to have to explain more thoroughly.
avatartommycoo
Status : No status yet...

Posts : 205
Join date : 2011-12-03
Age : 25
Location : indonesia
Sun 23 Mar 2014, 03:10
how can i make the chatbox autologin when we login to the forum ?
Sponsored content