I'm working on a site for a church who wants a member page that will display content specific to the department(s) that member belongs to. So, for instance, if the member works in the Children's Ministry, their member page will show only content designated for those working in the Children's Ministry. However, if a member works in both the Children's Ministry and the Music Ministry, they will see content designated for both the Children's and Music Ministries on their member page.
I am using the membership plugin to allow members to signup and manage their accounts. That is all working beautifully. What I am stuck on is how to display content specific to each member.
In CMSB, I have all members listed in the "User Accounts" section. Then, I have a multi-section called "User Categories". This section a display "title" and "database_name" along with associated content for each respective ministry/department. In the User Accounts section, I created a multi-value checkbox list called "user_category". Here, admins can assign the member to a category (i.e. ministry department) by checking the box or boxes corresponding to the content that member should be able to view (ex: checking the "Children's Ministry" box allows that member to view "Children's Ministry" content).
Right now, using the traditional "foreach" loop, every member sees the content for every department. I just need to know how to limit the content displayed on the page to only what that member is allowed to see based on their department designation in User Accounts.
I'm assuming a "where" clause would handle this, but everything I've tried so far hasn't worked. I'd really appreciate any insight. :-)
Thanks in advance,
Well, after a while of getting nowhere with this, I realized it would be easier to do this in reverse. Then, I stumbled upon this thread: https://www.interactivetools.com/forum/forum-posts.php?postNum=2202242#post2202242
Thanks to that thread, I managed to get things working. Yay! I'll go ahead and put what I did below, just in case it helps anyone (or in case I need to refer to it again in the future). :-)
Basically, I just created a multi-value pillbox called "members" in my "user_categories" section (which I may rename now) and pulled in "fullname" (for option labels) and "num" (for option values) from the user "accounts" section.
Then, in my viewer, I used the following "where" clause:
'where' => mysql_escapef(" members LIKE ? ", "%\t".$CURRENT_USER['num']."\t%" ),
Worked like a charm! :-)