Forums / Developer / Display info depending on Usergroup

"Please Note:
  • At the specific request of Ibexa we are changing this projects name to "Exponential" or "Exponential (CMS)" effective as of August, 11th 2025.
  • This project is not associated with the original eZ Publish software or its original developer, eZ Systems or Ibexa".

Display info depending on Usergroup

Author Message

John Kazakis

Friday 04 April 2008 6:01:44 am

Hello,

I'm trying to display different information depending on the usergroup of current_user.

The issue that I'm running into is that every user is part of the "Users" usergroup, so I can't seem to be to use {case match='Anonymous'}.

Here's the code that I'm using;

{foreach $user.groups as $key => $group}
	{def $group=fetch( 'content', 'object', hash( 'object_id', $user.groups[$key] ) )}

{let groupn=$group.name}

{switch name=pagetester match=$groupn}

{case match='IE07'}

        				<p>You are a member of: <strong>IE07</strong><br />
				You have access to the following sections:
				<ul>
					<li>Access to this</li>
					<li>and that</li>
				</ul></p>

{/case}

{case match='UE2'}

<p>You are a member of UE2</p>

{/case}

{case in=array(Anonymous, Users)}
			<p> You are an anonymous user.<br />
				You do not have access to this section, If you'd like to have access, please <a href="/publications/subscribe">click here</a>.
{/case}

{/switch}
{/let}
{/foreach}

This works only for anonymous, but when I log in as one of the other users, it doesn't seem to work. I am using {switch} because there will be about 10 usergroups.

John Kazakis

Monday 07 April 2008 4:57:22 am

Looks like I fixed this,

Used an if statement instead, so my code looks like this now

			{if $group.name|contains( IE07 ) }
				<p>You are a member of: <strong>Import/Export 2007</strong><br />
				You have access to the following sections:
				
 	 		{elseif $group.name|contains( UE2 )}
  				<p>You are a member of: <strong>UEII</strong><br />
				You have access to the following sections:	
			{elseif $group.name|contains( Anonymous )}
				<p> You are an anonymous user.<br />
				You do not have access to this section.

...

One thing I'd like to add is to display a message depending on the current node that the user is in. Is it possible? I've read about $requested_uri_string, but it seems it's only for pagelayout. Is there another way?

Thanks.