Member categories
The obvious limitation of ExpressioEngine membership system is that a member can be part of only one membership group. With Member categories, you can assign multiple categories to your members. Categories used are the channel categories, so you can easily relate "groups" of members to "groups" of entries.
Features:
- Display members belonging to category
- Display categories assigned to member
- Check whether a member belongs to certain category
- Display entries from member's category
- Assign categories on backend and frontend
Settings
Before using Member categories, you should select in module settings what category groups you want to be applicable for members. You can also optionally choose to automatically assign parent category for member, if the child category is assigned.
Note that if you're using MSM you'll have to provide settings for each site separately.
Display members belonging to category
{exp:member_categories:members category_id="1"}
Example:
Members in this category
{exp:member_categories:members category_url_title="{segment_3}" backspace="1"}
<a href="{path=profile/{username}}">{screen_name}</a>,
{if no_results}none{/if}
{paginate}{pagination_links}{/paginate}
{/exp:member_categories:members}
Parameters:
- category_id - the ID of category to get members
- category_url_title - URL title of category
- custom_fields="yes" - if set to "yes", will also fetch all custom profile fields data for each member
- backspace - number of character to be removed from the end of tag contents on last iteration
- errors="off" - if specified, all error messages will be suppressed
- limit - number of records per page (omit to disable pagination)
- order_by - field to order by. Any field from exp_members database table can be used. Defaults to member_id
- sort - sorting direction (asc, desc)
- paginate="top" - defines where pagination links should be displayed. Possible values: 'top', 'bottom', 'both' (defaults to bottom)
You MUST provide either category_id OR category_url_title
Variables (all having the same meaning that in member profile tag):
- member_id
- username
- screen_name
- url
- location
- occupation
- interests
- aol_im
- yahoo_im
- msn_im
- icq
- bio
- signature
- ip_address
- birthday
- avatar_url
- avatar_width
- avatar_height
- photo_url
- photo_image_width
- photo_image_height
- signature_image_url
- signature_image_width
- signature_image_height
- join_date format="%Y-%m-%d"
- last_visit format="%Y-%m-%d"
- last_activity format="%Y-%m-%d"
- my_custom_profile_field - custom profile fields are also available if you set parameter custom_fields="yes"
- total_results - overall number of categories to be displayed
- count - counter for each iteration (resets on every page)
- absolute_count - counter for each iteration (continuos thoughout pages)
- {if no_results}...{/if} - text to display if there are no results
- {paginate}{pagination_links}{/paginate} - pagination links
Display categories assigned to member
{exp:member_categories:categories member_id="1"}
Example:
This member belongs to categories:
{exp:member_categories:categories username="{segment_3}" backspace="1"}
<a href="{path=category/{category_url_title}}">{category_name}</a>,
{if no_results}none{/if}
{/exp:member_categories:categories}
Parameters:
- member_id - the ID of member to get categories. Defaults to logged in member ID.
- username - ... or username
- custom_fields="yes" - if set to "yes", will also fetch all custom profile fields data for each member
- category_group - you can restrict output to display only categories from certain groups. Provide one or several group IDs (seperate multiple values with a pipe, ex. category_group="2|3|12")
- backspace - number of character to be removed from the end of tag contents on last iteration
- order_by="order" - sort categories by category order. If omited, they will be sorted by category name
- sort - sorting direction (asc, desc)
- errors="off" - if specified, all error messages will be suppressed
Variables (all having the same meaning that in channel categories tag):
- category_id
- category_name
- category_url_title
- category_image
- category_description
- parent_id
- category_group - ID of category group
- my_custom_profile_field - custom profile fields are also available if you set parameter custom_fields="yes"
- total_results - overall number of categories to be displayed
- count - counter for each iteration
- {if no_results}...{/if} - text to display if there are no results
Check whether a member belongs to certain category
{exp:member_categories:check member_id="1" category_url_title="{segment_3}"}
Example:
{exp:member_categories:check username="{segment_3}" category_id="1"}
The member belongs to the category
{if no_results}The member does NOT belong to the category{/if}
{/exp:member_categories:check}
Parameters:
- member_id - the ID of member to check. Defaults to logged in member ID.
- username - ... or username
- category_id - the ID of category to check
- category_url_title - ... or URL tite
- errors="off" - if specified, all error messages will be suppressed
You MUST provide category_id (or category_url_title)
You can also pass multiple category IDs to check whether member belong to at least one category. Use pipe (|) separator for category_id parameter. E.g. category_id="1|7|12"
The contents of tag pair will be returned if there is a match between member and category. Otherwise the contents of {if no_results} block will be returned. No additional variables are available.
Display entries from member's category
To display entries from the same category that member belongs to, you can use combination of {exp:member_categories:categories} and {exp:channel:entries} tags.
{exp:member_categories:categories username="{segment_3}"}
Category: {category_name}, entries:
{exp:channel:entries category="{category_id}" dynamic="no" backspace="1"}
<a href="{path=view/{url_title}}">{title}</a<,
{if no_results}none{/if}
{/exp:channel:entries}
{if no_results}none{/if}
{/exp:member_categories:categories}
Assign categories on backend and frontend
From the module control panel, you can assign any number of categories to member by checking the appropriate checkboxes. Just like you do with categories for entries.
Note that if you're using MSM only category groups for current site are displayed (and only those defined in settings).
If you have Member categories module installed, you can use SA Member Edit to enable users editing their categories on the frontend.
To assign categories from the front-end, place {exp:member_categories:form} tag pair somewhere in your templates. The tag pair has only one variable — {categories}, which return pre-formatted list of categories checkboxes. If you want to edit the way categories are displayed, you need to edit categories_edit.php file in views folder.
You can also edit categories using Stand-Alone Member Edit module
My categories:
{exp:member_categories:form}
{categories}
<input type="submit" value="Save" />
{/exp:member_categories:form}