Gossamer Forum
Quote Reply
if group
I'd like to do something like:

<%if group_id = 3%>
Hiya in group 3
<%endif%>

I would imagine this to be possible via a new global, but have no idea how to make such.

Any ideas?
Quote Reply
Re: [gotze] if group In reply to
Could probably do it with something like this;

Code:
sub {

my $id = '3';

my $table = $DB->table('UserGroup');
my $chk = $table->count( { group_id_fk => $id, user_id_fk => $USER->{user_id} } ) || 0;

if ($chk > 0) {
return 1;
} else {
return 0;
}

# Basically, the query is:
# SELECT COUNT(*) FROM forum_UserGroup user_id_fk => $USER->{user_id} group_id_fk= 5
# This checks to see if the user is a member of the group specified
}

Call with;

<%global_name%>, and it should pick up their user_id if they are logged in :)

Hope that helps.

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!