Gossamer Forum
Home : Products : DBMan SQL : Discussion :

Logged in User

Quote Reply
Logged in User
   

Hi,

I am using the following sub in a template global to pull a field from another table. How do I get it to determine the username of the person who is logged in?

Is there a set variable that can be used in the template global sub?

sub {
my ($field_name) = $DB->table('table_name')->select({'Username' => ??Logged in user?? }, ['field_name'])->fetchrow_array();
return $field_name;
}


Thank you.

Simon.
Quote Reply
Re: [jai] Logged in User In reply to
All logged user information are already available in the template tags =). So try to edit your code like

Code:


sub {
my $tags = shift;
my ($field_name) = $DB->table('table_name')->select({'Username' => $tags->{Username} }, ['field_name'])->fetchrow_array();
return $field_name;
}
Cheers,

jean(at)Gossamer Threads
Quote Reply
Re: [jean] Logged in User In reply to
Thanks that works fine!!

Now I want to assign the result to a new global tag (e.g <%new_name%> = $field_name) that will be available after the subroutine is executed.

What do I need to add to my subroutine to make this work???

Thank you.

Simon.