Gossamer Forum
Home : Products : Gossamer Forum : Discussion :

If a User is a member of a special group

Quote Reply
If a User is a member of a special group
Hi:

OK, this is probably about as lame a question as you will see today, and I hope it is an easy one.

If I wanted to make a special group, leats call it "GT" to be easy... and I wanted certain things to appear ONLY to members of that group, how would write that? Something like:

<%if User:Group:GT%>

or something like that?

Thanks!
dave

Big Cartoon DataBase
Big Comic Book DataBase
Quote Reply
Re: [carfac] If a User is a member of a special group In reply to
As far as I know you'd need a global, something like:

Code:
sub {
return $DB->table('UserGroup', 'Grouping')->select('group_name', { user_id_fk => $_[0] })->fetchrow;
}

You'd call it like:

<%if the_global($user_id) eq 'GT'%>

*I think* ... do a <%GT::Template::dump%> to find the exact tag for the user id.

Last edited by:

Paul: Mar 20, 2003, 11:48 AM
Quote Reply
Re: [Paul] If a User is a member of a special group In reply to
Paul:

Thanks! I used your code, named the global "group" and then did a dump, and in the dump, "group" was = to: $VAR = 'CODE(0x9d8ed68)';


So I am guessing there is something wrong in there somewhere...
dave

Big Cartoon DataBase
Big Comic Book DataBase

Last edited by:

carfac: Mar 20, 2003, 12:27 PM
Quote Reply
Re: [carfac] If a User is a member of a special group In reply to
Oh, wait. Nevermind- I figured it out!
dave

Big Cartoon DataBase
Big Comic Book DataBase
Quote Reply
Re: [carfac] If a User is a member of a special group In reply to
It's a global in the form of an anonymous sub-routine which will appear as CODE( ... ) when you do a dump :)

Likewise if you try to print any other sort of perl reference you will see the memory reference, eg...

print \'';

...would print something like:

SCALAR(0x18326b4);
Quote Reply
Re: [Paul] If a User is a member of a special group In reply to
Paul:

Thank you for your help... it works very well. What I am doing- in case you care- is taking banner ads OFF the site for some members... moderators, those who donate, etc. I thought it would be a nice addition for those people!

Once I looked at the dump, and saw all the "current_user_xxx" info, I realized I could just add "user_member" to the forum_user" table, and get a "0" or "1" out without a global... so, I just did a

<%ifnot current_user_member eq '1'%>banner code<%endif%>

and it works stellar!

Thanks- now to do the same to my Links install!
dave

Big Cartoon DataBase
Big Comic Book DataBase
Quote Reply
Re: [Paul] If a User is a member of a special group In reply to
Hi Paul,

I tried your solution, but it doesn't work.

The tag <%the_global($user_id)%> prints only "Registered Users" (it doesn't consider the custom groups). So "<%if the_global($user_id) eq 'GT'%>" will always be false. Unsure Any idea?

Thank you very much for your help.

François