hi, i'm setting up an irc-chatroom for my website and i wanted to know how i can 'get' the username from the forum
example:
i'm logged in and i click on the chat button
the chat window opens and i get a chat with the username from the forum (automatically)
the code to put automatically a nickname in the chatwindow is
<param name="nick" value="yournickname">
(where "yournickname" stands, there needs to come a code for the forumusername...
if this is in any way part of the forum, then it's simple as $user_info['username'] or $user_info['name']
otherwise you'll need SSI.php or the api script!
Lainaus käyttäjältä: Aquilo - maaliskuu 14, 2007, 10:51:33 IP
if this is in any way part of the forum, then it's simple as $user_info['username'] or $user_info['name']
otherwise you'll need SSI.php or the api script!
no, it is an external page outside the forum, but maybe i can include ssi.php and take a bit of source and put it in ssi.php??
do you know how??
I don't know how but have you taken a look at the intergrated chat mod to see how they did it?
i'm trying to do it ... and i've tried this:
<?php
function username()
{
global $user_info;
if ($user_info['is_guest'])
echo 'gast';
else
echo '($user_info['name'])'; // <=here is the error!
}
?>
but i get the error 'parse error, unexpected T_STRING, expecting ',' or ';' in /home/www/the-elite.freehostia.com/forum2/SSI.php on line 1662', line 1662 is the line under 'else' ...
and, now i've took a look to the integrated chat mod but they did it totally different than i did..
sorry for my bad english, but it is better than YOUR dutch, i think...
If you have ever seen me speak Dutch you would be certain that I should only speak English. Anyhow - their method works and all I can say is that I would try to go with that as your example if possible. If not then there maybe more in the API for either SMF or for your IRC server that you can look into but the user_info['name'] variable should be what you are looking for. Remember you will need user_info registered as a global to do so effeciently like you have already.
but it doesn't work, i have a 'backup plan' but it doesn't work neither, and, i'm right: my english is better than your dutch!
heb ik geen gelijk?? :p
ja bent u juist. ;)
you are wrong
this is correct: ja, u bent juist (very polite)
or: ja, je hebt gelijk (between 2 friends)
or in dialect: ge hed het just
Change your code above to:
<?php
function username()
{
global $user_info;
echo ($user_info['is_logged']) ? $user_info['name'] : 'gast';
}
?>
This should work :)
edit: the error was caused by a mod, but now it always says 'gast' (guest in english) even when i'm logged in in smf, you can see the forum here (http://the-elite.freehostia.com/forum2) and the chat here (http://the-elite.freehostia.com/chat/test.php)
There is no $user_info['is_logged']. Try using this instead:
function username()
{
global $context;
echo ($context['user']['is_logged']) ? $context['user']['name'] : 'gast';
}
1 more question: is it possible to let the script determine that the username is 1 or more words? because my login is ome joop and when i login to the chat only ome is visible... so when it are 2 words it wil give the name of the user and not the username..
function username()
{
global $context;
echo str_replace(' ', '_', ($context['user']['is_logged']) ? $context['user']['name'] : 'gast');
}
thanx, this helps.