ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Show channel entries from members within the same member group

November 13, 2012 6:22pm

Subscribe [0]
  • #1 / Nov 13, 2012 6:22pm

    ciadeveloper

    10 posts

    I’ve been trying to find a solution to this issue all afternoon and I can’t seem to get it knocked out, so hopefully someone here can help.

    The system I am developing will have multiple member groups (one group per organization) and multiple members per member group.  What I’d like to have is the ability for a member to view a list of all channel entries made by anyone within their member group.  The different parameters of the “exp:channel:entries” template I’ve attempted are:

    {exp:channel:entries channel="channel_name" search:agency_id={logged_in_group_id} }

    Where “agency_id” is the member group id that has been saved to the entry as a channel field.

    {exp:channel:entries channel="channel_name" group_id={logged_in_group_id} }

    I’ve also tried various combinations of “logged_in_group_id”, “group_id” with and without quotes and braces.  The results end out displaying either all the channel entries (regardless of group) or no channel entries.

    Can anyone direct me to the parameters that would give me the channel entries created by anyone in the same member group as the logged in user?

    —Christian

  • #2 / Nov 15, 2012 3:02pm

    Dan Decker

    7338 posts

    Hi Christian,

    Ahhh, welcome to ExpressionEngine’s Parse Order.

    logged_in_group_id is parsed after channel entries, so it’s not available to be used as a variable.

    What you want to do is set these permissions in the each group’s Member Group Preferences. Check the options in these screenshots.

  • #3 / Nov 15, 2012 3:42pm

    ciadeveloper

    10 posts

    I’m not sure how those options will achieve my goal (afterall, I’ve already adjusted those).  Let me explain with more detail.  I have two member groups A and B (eventually there will be hundreds for this particular site).  Members 1, 2 and 3 belong to group A.  Members 6 and 7 belong to group B.

    When member 1 is logged in, I want to be able to display a list of channel entries authored by member 1, 2 or 3, but not 6 and 7.  I do not want members of group B to be able to see entries from group A (and vice-versa) on this particular page.  There are multiple reasons behind this requirement including providing the member a list of entries specifically for that organization/group and there also being an edit option on that list.

    So, if I am unable to use any of the ExpressionEngine template variables to pre-populate the ‘group_id’ parameter of the ‘exp:channels:entries’ template I have another idea.  I could turn on PHP for this template and set it to parse during the input stage.  I can then grab the members group id from

    $this->EE->session->userdata['group_id']

    and use that in the ‘exp:channel:entries’ template. 

    I haven’t tried it (yet), but seems like the only solution unless someone comes up with a better idea for me to try.
    —Christian

  • #4 / Nov 19, 2012 5:07pm

    ciadeveloper

    10 posts

    As an update, grabbing the user’s group id from the EE session variable via PHP during ‘pre-template processing’ and populating the group_id parameter of the channel entries template worked just fine. 

    So, unless there is some concern about using this method, issue closed.
    —Christian

  • #5 / Nov 20, 2012 3:54pm

    Dan Decker

    7338 posts

    Hi Christian,

    I’m glad you have found a solution! There is nothing wrong with using PHP like this, so no worries!

    If you have any other questions, please let me know.

    Cheers,

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases