GB Member Select
The GB Member Select is like an EE Relationships field but instead of listing the channel entries, it lists the members by the selected member roles (or groups for EE5 folks).
Installation
Upload the folders to the respective system/user/addons/
and themes/user/
directories and click install on the Add-Ons page.
MySQL Info
ANY_VALUE
If your database engine supports ANY_VALUE, please go to system/user/addons/gb_member_select/Service/
and replace MemberSelectService.php
with MemberSelectService.php.ANY_VALUE
.
Member custom fields
If you have many custom member fields, please make sure adjust the sort_buffer_size
value in the settings page.
Field Settings
Member Roles/Groups
Select the member roles/groups that you want the field to show members from.
Default Label
The default label representing the member. It is also used for the selector options.
Extra Identifiers
Specify the fields that you want to use when searching the members.
Maximum Members
The usual stuff. You can still search for the members not presented in the list using the filter and search box.
Allow multiple members?
I think it works 😉
Include in search?
Still working on this…
Usage in templates
Parameters
var_prefix
backspace
Variables
Trying my best to match the {exp:member:memberlist}
fields without impacting performance. Reach out to me if what you are looking for is not here.
{screen_name}
{username}
{email}
{member_id}
{avatar_filename}
{avatar_width}
{avatar_height}
{photo_filename}
{photo_width}
{photo_height}
{sig_img_filename}
{sig_img_width}
{sig_img_height}
{ip_address}
{join_date}
{last_visit}
{last_activity}
{total_entries}
{total_comments}
{total_forum_topics}
{total_forum_posts}
{last_entry_date}
{last_comment_date}
{last_forum_post_date}
{in_authorlist}
{language}
{timezone}
{member_custom_field}
{roles} {role:role_id} {role:name} {/roles}
(EE6)
{member_groups} {group:group_id} {group:group_title} {/member_groups}
(EE5)
Examples
{my_custom_field}
{if no_results}No related members.{/if}
{screen_name}
{username}
{email}
{member_id}
{!-- You can call the default fields listed above and custom member fields by the short_name --}
{path:avatar}
{member_custom_field}
{!-- EE6 --}
{roles}
{role:role_id}
{role:name}
{/roles}
{!-- EE5 --}
{member_groups}
{group:group_id}
{group:group_title}
{/member_groups}
{/my_custom_field}
{my_custom_field var_prefix="my_prefix"}
{my_prefix:screen_name}
{my_prefix:username}
{my_prefix:email}
{my_prefix:member_id}
{my_prefix:path:avatar}
{my_prefix:member_custom_field}
{!-- EE6 --}
{my_prefix:roles}
{role:role_id}
{role:name}
{/my_prefix:roles}
{!-- EE5 --}
{my_prefix:member_groups}
{group:group_id}
{group:group_title}
{/my_prefix:member_groups}
{/my_custom_field}
{grid_with_gbms}
{grid_with_gbms:my_custom_field var_prefix="my_prefix"}
{my_prefix:screen_name}
{my_prefix:username}
{my_prefix:email}
{my_prefix:member_id}
{my_prefix:path:avatar}
{my_prefix:member_custom_field}
{!-- EE6 --}
{my_prefix:roles}
{role:role_id}
{role:name}
{/my_prefix:roles}
{!-- EE5 --}
{my_prefix:member_groups}
{group:group_id}
{group:group_title}
{/my_prefix:member_groups}
{/grid_with_gbms:my_custom_field}
{/grid_with_gbms}
{my_custom_field backspace="1"}{member_id},{/my_custom_field}
Note: The {if no_results}
condition doesn’t work well in {exp:channel:form}
tags, I’ll address it in future releases.
Want a selector?
Sure! Here’s how you print a <select>
HTML tag:
{exp:channel:entries entry_id="{entry_id}" status="not closed"}
{exp:gb_member_select:selector
field_name="my_custom_field"
name="selector"
attr:id="my_selector"
attr:class="form-control select-reporter"
option_label="screen_name"
option_value="email"
selected="{my_custom_field backspace="1"}{member_id},{/my_custom_field}"
show_empty="yes"
empty_label="Select a member"}
{/exp:channel:entries}
{exp:gb_member_select:selector
field_name="my_custom_field"
name="selector"
attr:id="my_selector"
attr:class="form-control select-reporter"
option_label="screen_name"
option_value="email"
selected="{exp:channel:entries entry_id='{entry_id}' status='not closed'}{my_custom_field backspace='1'}{member_id}{/my_custom_field}{/exp:channel:entries}"
show_empty="yes"
empty_label="Select a member"
parse="inward"}
Parameters
field_name (required)
The field short_name.
name
The name=""
of your <select>
. Default to the field short_name.
selected
Member ids separated by ,
to be pre-selected.
option_label
What member field to be displayed as the option. Default to the field settings Default Label.
option_value
What member field to be used as the option value. Default to member_id
.
Allowed member fields
screen_name
username
email
member_id
member_custom_field
show_empty
Set to yes
if you want the first option to be blank.
empty_label
If show_empty="yes"
, the text you want to display as the blank option. Default to --
.
attr:attribute
You can add HTML attributes like id attr:id="selector"
, class attr:class="form-select"
and data attributeus like attr:data-entry_id="{entry_id}"
.
Reverse Lookup
GB Member Select lets you lookup the entries you’ve related the members to with any gb_member_select fieldtype by using the {exp:gb_member_select:entries}{/exp:gb_member_select:entries}
tag pair.
Parameters
Almost exactly like {exp:channel:entries}{/exp:channel:entries}
with 2 more filters:
member_id
The member_id of the member that you want to reverse lookup the entries with. If not specified, the current logged in member will be used to do the reverse lookup.
field_name
The short name of the gb_member_select field that you want to return the related entries from. If not specified, every gb_member_select field will be used to find the entries related to the member.
Examples
Since the gb_member_select entries loop shares exact same variable names with the channel entries loop, please put the gb_member_select entries loop inside an embed if used together. For example, if you have a gb_member_select field called article_by
and you’d like to display the related work from this member:
article/item
{exp:channel:entries channel="featured_articles" status="not closed"}
<h2>{title}</h2>
<p>{summary}</p>
<section class="related">
{embed="_includes/_articles_by" member_id="{article_by}{member_id}{/article_by}"}
</section>
{/exp:channel:entries}
_includes/_articles_by
{exp:gb_member_select:entries status="not closed" member_id="{embed:member_id}" field_name="article_by"}
<h3>{title}</h3>
{/exp:gb_member_select:entries}
Caching
To improve performance, GB Member Select caches the field members for each defined GB Member Select field using the EE cache class. If you have a huge list of members (100,000+) that you want to include in a selector, you might need to adjust your PHP memory_limit and max_execution_time to appropriate settings.
There’re also 2 cache status pages in GB Member Select’s add-on settings that you can generate the cache for the fields and entries. If you turn on flush cache settings in the GB Member Select settings page, these cached results will automatically be cleared upon
- after_member_insert
- after_member_update
- after_member_delete
- member_anonymize
- after_member_field_update
- after_member_field_delete
or set to out of sync
for the affected fields and channels.
Selected members in entries are also cached, and will automatically get flushed and recreated upon modifications.
Future Goals
- Publisher support
Changelog
2.0.3
Fixed
- Entry not saving due to deleted member roles
2.0.2
Added
- Including more native member fields to match the memberlist
2.0.1
Fixed
- Bug with filtering without selected member
2.0.0
Added
- Grid support
sort_buffer_size
config- Flush cache page
Updated
- Making ANY_VALUE optional
- Improved search functionality
Fixed
- Jump menu links updated
Deprecation notice
- This will be the last minor version I’m supporting EE5
1.2.1
Fixed
- Installation error with class name
1.2.0
Added
- Migration from
user_select
andvmg_chosen_member
togb_member_select
Fixed
- EE6 Bug
1.1.0
Added
{exp:gb_member_select:entries}
to reverse lookup the entries- Cache status pages
Updated
- Enhanced member processing
- Enhanced caching mechanism
Fixed
- Frontend bug with the entry_id
1.0.0
- Hello World!
Support
Email Gilbert at gilbert.lin.web@gmail.com