AB Member Categories documentation

AB Member Categories lets you link custom member fields to category groups. It's a simple concept - but also a very powerful one. If you think about it a category group is just a list ... it can be a list of member groups, a list of teams or any other kind of category you'd like to put your members in. You can link as many member fields to as many category groups you want. For each linked field, members can be put in either one or multiple categories.

Installation

  • Download and unzip member_categories.ee2_addon.zip
  • Upload everything in “system/expressionengine/third_party/” to /system/expressionengine/third_party/ on your server
  • Upload everything in “themes/third_party/” folder to /themes/third_party/ on your server
  • In ExpressionEngine, navigate to Addons → Modules and click “Install” next to the “Member Categories” addon
  • That’s it! Click the “Member Categories” in the modules list to get to the settings page where you can link your custom member fields to category groups.

Linking

A category group in EE is a collection of categories. From the Member Categories settings page you can connect any of your existing custom member fields to a category group. For each field you also have the option to specify that multiple categories may be selected.

Once a Custom Member Field -> Category Group link has been made the categories from that category group will show up in a dropdown list on the member's Edit Profile page.

Editing a member

Here's an example of editing a member with two fields linked with Member Categories (the Member Category and the Team field). As seen above the Member Category field allows multiple, while the Team dropdown is for selecting a single team.

Please note that the dropdowns shown in these images use a third-party library called Chosen. This has now been disabled by default as it had a bug where the dropdowns would be cut off if it was at the bottom of the edit member page. It might work with your setup though - you can enable it by editing config/member_categories.php (and setting the chosen_enabled flag to TRUE)

Here's how a single select looks:

And here's how it will look if you tick the "Allow multiple" checkbox when linking the field:

Tags

Of course, the power of this addon is in the tags and the things you can build with them.

{exp:member_categories:check}

This tag is used to check if a member belongs in specific categories. You specify the custom member field name, the categories to check for and the member_id.

The tag can be used for to check for team memberships, advanced access control, etc.

Parameters:

  • field: the short name of the custom member field to check
  • category: the short name of the category to check if the user belongs to (you can enter multiple here, separating them with a pipe: |)
  • member_id: (optional, will default to the currently logged in member)
  • tag_prefix: (optional, replace the default "mc:" tag prefix with something else).

Available tags

This tag will make the mc:belongs_in_allmc:belongs_in_any and mc:belongs_in_none conditionals available. Here's an example of a template which checks for user access:

{if logged_in}
<h1>Hi {screen_name}</h1>

{exp:member_categories:check field="member_category" category="super_admins|priority_members"}

{if mc:belongs_in_all}
<p>You're both a super admin AND a priority member - how is that even possible?</p>

{embed="embeds/.priority_users"}
{/if}

{if mc:belongs_in_any}

<p>Wow, seems you're either a super admin or a priority member! We'll embed some goodies for you:</p>

{embed="embeds/.priority_users"}

{/if}

{if mc:belongs_in_none}
<p>Doh, you're just a regular member aren't you?</p>
{embed="embeds/.please_upgrade"}
{/if}

{/exp:member_categories:check}
{/if}

{exp:member_categories:members}

Use this tag to list the members of a specific category.

Parameters

  • field: required - the short name of the custom member field to check
  • category: required - the category_url_title of the category to check
  • tag_prefix: optional, use this if you want to change the default mc: tag prefix.

Available Tags

  • {mc:has_results} - conditional to check whether or not any results were returned
  • {mc:total_results} - the number of results
  • {mc:results} - a loop for the members (this contains {mc:member_id}, {mc:screen_name} and {mc:email} - if you need more member information use EE's native {exp:member:custom_profile_data} tag)
{exp:member_categories:members field="team_id" category="{segment_3}"}
<h2>Total members: {mc:total_results}</h2>

{if mc:has_results}
<ul>
{mc:results}

<li>{mc:member_id}: {mc:screen_name}</li>

{!-- // this can also be used btw:

{exp:member:custom_profile_data member_id="{mc:member_id}"}
{screen_name}..
{/exp:member:custom_profile_data}
--}
{/mc:results}
</ul>

{if:else}
No members, yet.
{/if}

{/exp:member_categories:members}

{exp:member_categories:categories}

Use this tag to list the categories available for a specific member field.

Parameters

  • field: required, the short name of the custom member field
  • orderby: optional, specify the col to order by (defaults to 'cat_order')
  • sort: optional, specify sort (asc/desc) - defaults to asc.
  • tag_prefix: optional, change the "mc:" tag prefix.

Available Tags

  • {mc:has_results} - conditional to check whether or not any results were returned
  • {mc:total_results} - the number of results
  • {mc:results} - a loop for the categories - contains the following tags: {mc:cat_id}{mc:group_id}{mc:parent_id}{mc:cat_name}{mc:cat_description}{mc:cat_url_title}{mc:cat_image}{mc:cat_order}.
{exp:member_categories:categories field="team_id"}

{if mc:has_results}

<h1>Teams ({mc:total_results})</h1>

<ul>
{mc:results}
<li><a href="{path=mc/teamlist}/{mc:cat_url_title}">{mc:cat_name}</a></li>
{/mc:results}
</ul>
{if:else}
<h1>No Teams</h1>
{/if}
{/exp:member_categories:categories}