Advertisement:

get username

Aloittaja vandeperre, maaliskuu 14, 2007, 04:58:40 IP

« edellinen - seuraava »

vandeperre

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...

Aquilo

#1
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!

vandeperre

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??

KGIII

I don't know how but have you taken a look at the intergrated chat mod to see how they did it?

My PC Support Forum
Please ask in-thread before PMing
                   SMF Help
                   Visit My Blog

How can we improve the support process?:
http://www.simplemachines.org/community/index.php?topic=163533.0

SMF vs. Godzilla? Who do you think will win?

vandeperre

#4
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' ...

vandeperre

#5
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...

KGIII

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.

My PC Support Forum
Please ask in-thread before PMing
                   SMF Help
                   Visit My Blog

How can we improve the support process?:
http://www.simplemachines.org/community/index.php?topic=163533.0

SMF vs. Godzilla? Who do you think will win?

vandeperre

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

KGIII


My PC Support Forum
Please ask in-thread before PMing
                   SMF Help
                   Visit My Blog

How can we improve the support process?:
http://www.simplemachines.org/community/index.php?topic=163533.0

SMF vs. Godzilla? Who do you think will win?

vandeperre

#9
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

Daniel15

Change your code above to:

<?php 
function username()
{
global $user_info;
echo ($user_info['is_logged']) ? $user_info['name'] : 'gast';
}
?>



This should work :)
Daniel15, former Customisation team member, resigned due to lack of time. I still love everyone here :D.
Go to smfshop.com for SMFshop support, do NOT email or PM me!

vandeperre

#11
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 and the chat here

codenaught

There is no $user_info['is_logged']. Try using this instead:

function username()
{
global $context;
echo ($context['user']['is_logged']) ? $context['user']['name'] : 'gast';
}
Dev Consultant
Former SMF Doc Coordinator

vandeperre

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..

Aquilo

function username()
{
global $context;
echo str_replace(' ', '_', ($context['user']['is_logged']) ? $context['user']['name'] : 'gast');
}

vandeperre


Advertisement: