This document provides an overview of the MemberShortCode class, including available parameters, customization hooks, and example usage.
Shortcode Usage
To use the MemberShortCode, insert the following shortcode in a page or post:
[members-listing title="Active Members" per_page="5" type="active"]
Shortcode Parameters
| Parameter | Type | Description |
|---|---|---|
title |
string | Title displayed above the member listing. |
type |
string | Specifies the order: active, random, newest, popular, online, or alphabetical. |
page |
int | Page of results to display. |
per_page |
int | Number of members per page. |
max |
int/bool | Maximum number of members displayed. |
include |
int/array | Limit results to specified member IDs. |
exclude |
int/array | Exclude specified member IDs from results. |
user_ids |
int/array | Array or comma-separated list of IDs to display. |
include_member_role |
string | Limit to specific WordPress roles (comma-separated). |
exclude_member_role |
string | Exclude specific WordPress roles (comma-separated). |
member_type |
string | Limit results to specific member types (comma-separated). |
member_type__in |
string | Limit results to a list of member types. |
member_type__not_in |
string | Exclude specified member types from results. |
role__in |
string | Include members with specific roles. |
role__not_in |
string | Exclude members with specific roles. |
meta_key |
string | Filter results by the presence of a specific user meta key. |
meta_value |
string | Filter results by matching user meta value. |
pagination |
string | Display pagination (yes or no). |
grid |
string | Display members in a grid (yes or no). |
loop_layout |
string | Number of columns in grid layout (two, three, four). |
container_class |
string | CSS class for container, default is members. |
Filters and Actions
Filters
member_shortcode_attributes
Description: Modify attributes of the shortcode.
Usage Example:
add_filter( 'member_shortcode_attributes', function( $atts ) {
$atts['per_page'] = 10;
return $atts;
});
member_shortcode_bash_query_args
Description: Customize the query arguments.
Usage Example:
add_filter( 'member_shortcode_bash_query_args', function( $query_args ) {
$query_args['type'] = 'newest';
return $query_args;
});
member_shortcode_template_args
Description: Modify template arguments passed to the shortcode template.
Usage Example:
add_filter( 'member_shortcode_template_args', function( $args ) {
$args['column'] = 'two';
return $args;
});
member_shortcode_output
Description: Adjust the final output of the shortcode.
Usage Example:
add_filter( 'member_shortcode_output', function( $output ) {
return '' . $output . '';
});
Actions
before_member_shortcode_render
Description: Fires before rendering the member content.
Usage Example:
add_action( 'before_member_shortcode_render', function( $atts ) {
echo 'Preparing Member Listing...
';
});
member_shortcode_before_output
Description: Fires right before the output of the member container.
Usage Example:
add_action( 'member_shortcode_before_output', function( $atts ) {
echo 'Before Output';
});
member_shortcode_inside_container
Description: Fires inside the container, allowing content insertion.
Usage Example:
add_action( 'member_shortcode_inside_container', function( $atts, $template_args ) {
echo 'Inside Member Container';
}, 10, 2 );
after_member_shortcode_render
Description: Fires after the member content is rendered.
Usage Example:
add_action( 'after_member_shortcode_render', function( $args ) {
echo 'Member Listing Complete
';
});
Example Shortcode Configurations
Example 1: Active Members with Grid Layout
[members-listing title="Active Members" type="active" per_page="5" grid="yes" loop_layout="three"]
Explanation: Shows active members in a 3-column grid layout.
Example 2: Alphabetical List of Members
[members-listing title="Alphabetical Members" type="alphabetical" orderby="name" per_page="10" grid="no"]
Explanation: Displays an alphabetical list of members with 10 per page in list format.
Example 3: Members by Specific Role
[members-listing title="Administrators Only" include_member_role="administrator" per_page="6" grid="yes"]
Explanation: Shows only members with the role of administrator, 6 per page, in a grid format.
Example 4: Exclude Specific Members by ID
[members-listing title="Featured Members" exclude="101,102,103" type="newest" per_page="5"]
Explanation: Displays the newest members but excludes members with IDs 101, 102, and 103.
Example 5: Recent Members with Pagination
[members-listing title="New Members" type="newest" per_page="5" pagination="yes"]
Explanation: Shows the 5 most recent members per page with pagination enabled.
This documentation provides an in-depth overview of using MemberShortCode with various configurations and customization options using filters and actions.
