CGUserDirectory filter search result based on group

Do something cool with CMS? Show us ...
This board is for 'Answers', and the discussion of answers... Not for questions.
Post Reply
webform
Power Poster
Power Poster
Posts: 363
Joined: Sat Nov 25, 2006 3:39 pm
Location: Copenhagen, Denmark

CGUserDirectory filter search result based on group

Post by webform »

If you use {CGUserDirectory group="members"} in a page you can filter what users to see in the list. But if you do a search on user properties the result also shows users not belonging to that group.

My way around it is this little trick in the summary template:

Code: Select all

{foreach from=$users item='oneuser'}

{foreach from=$oneuser.groups item='onegroup'}
      {assign var="groupname" value=$groups.$onegroup.groupname}
{/foreach}

{if $groupname == "members"}
Show content.
{/if}

{/foreach}


NB! This won't work if a user belong to several groups

Hope someone finds it useful.
Last edited by webform on Thu Nov 11, 2010 3:43 pm, edited 1 time in total.
vfreriks
Forum Members
Forum Members
Posts: 22
Joined: Wed Jul 14, 2010 9:41 am

Re: CGUserDirectory filter search result based on group

Post by vfreriks »

Thanks a bunch! This saved me from alot of work!
Post Reply

Return to “Tips and Tricks”