TinyPortal

Development => Support => Topic started by: Zetan on May 06, 2007, 04:37:18 PM

Title: Member Name in php?
Post by: Zetan on May 06, 2007, 04:37:18 PM
Does anybody know what pulls the member name into the User block, or where it displays "Hello Zetan"?
I've been searching for a while now, and nothing I've tried works.

Here is how I'm trying to use it:

.php block
elseif (in_array(4, $user_info['groups']))
echo '
Text Text Text, USERNAME HERE, TEXT.
';


I want to display the member name of the person logged in, in a php block.

Thanks


ZTN
Title: Re: Member Name in php?
Post by: G6Cad on May 06, 2007, 04:45:00 PM
Have you checked the block code and snippets board Zetan ?
I think there is a block made this way already, or if it was a request  ???
I know i have read it in here some time ago though.

Also SMF have the docsection where they have a lot info on how to pull in things diffrent way to the theme or site.
Title: Re: Member Name in php?
Post by: Zetan on May 06, 2007, 04:56:30 PM
I've looked at the snippets.. I seem to get errors with the way I try, I've been looking through the doc section at SMF.
http://support.simplemachines.org/function_db/index.php

I so wanted to be clever and do it myself../me is still a code n00ber  :uglystupid2:
Title: Re: Member Name in php?
Post by: Nokonium on May 06, 2007, 06:37:28 PM
If it is any help

// If the user is logged in, display stuff like their name, new messages, etc.
if ($context['user']['is_logged']){
echo '<span class="normaltext">', $txt['hello_member'], ' <b>', $context['user']['name'], '</b></span>';


$txt['hello_member'] = 'Hey,';
Title: Re: Member Name in php?
Post by: Zetan on May 06, 2007, 06:57:32 PM
Thanks.. it doesn't work in the middle of my echo statement.
Theres few things in the script and it works as it is, I just want to add the member name.

Some random words here, MEMBER NAME, Some more words paragraphed here.

I'm sure it does work on it's own, but it gives me this error:
Parse error: syntax error, unexpected '<' in /home/zetan/public_html/somesite/Sources/Load.php(1737) : eval()'d code(35) : eval()'d code on line 15

I've been staring at it for a few days and I'm sure it's really simple. I have to go out, I'll stare at it some more later.
Title: Re: Member Name in php?
Post by: Nokonium on May 06, 2007, 07:07:58 PM
Quoteunexpected '<'

Quite often means that you need to add before an echo' and a '; at the end.
Title: Re: Member Name in php?
Post by: Zetan on May 06, 2007, 07:10:55 PM
Thank you, I will have to fix it later .. It's Bank Hols here this weekend... Theres beer to drink with friends in the pub  :buck2:
Title: Re: Member Name in php?
Post by: bloc on May 06, 2007, 07:42:50 PM
the variable for the member name is quite easy..and the whole "hello" string goes like:

echo $txt['hello_member_ndt'] , ' ' , $context['user']['name'];