mycred_users_of_rank

Description

This shortcode returns a list of users for a specific published role, ordered by their account balance. By default all users are returned for the given rank but you can set how many users to return.

If you want to customize the layout of each row, you can create your own template and wrap this shortcode around it. This way, your html template will be used for each user row. Supports the use of shortcodes and user related template tags.

Requires the Ranks add-on to be enabled.

Available since version 1.3

Shortcode Attributes

Attribute Type Required Default Description
rank_id int or string Yes - The rank ID or rank title (case sensitive) to show users for.
login string No - Message to show to visitors if they are not logged in. Should be left empty if you want to show ranks to visitors as well.
number int No 10 The number of users to show for each rank.
wrap string No 1 The HTML element to wrap around each user.
col int No 1 Optional colspan to set if you are using a table as your wrapping element and no users were found.
nothing string No "No users found with this rank" Optional text to show when no users were found for this rank.
ctype string No mycred_default Option to show ranks of a particular point type. Should not be used if you only have one point type installed.
order string No DESC The order of the ranks. Accepts "DESC" for descending and "ASC" for ascending.

CSS Styling

// Wrapper
div.mycred-users-of-rank-wrapper { }

// Default row template
div.mycred-users-of-rank-wrapper p.user-row { }

Examples

Example 1: Return the top 2 users for the rank “Newbie”.

[mycred_users_of_rank rank_id=4 number=2]

Example 2: Show users of the rank with ID 4 in an unorganized list.

[mycred_users_of_rank rank_id=4 wrap="ul"]
<li>%rank_logo% %display_name%</li>
[/mycred_users_of_rank]

Example 3: Return all users for the rank “Beginner” and customize the template to create a table.

<table>
	<thead>
		<tr>
			<th class="logo"></th>
			<th class="name">User</th>
			<th class="balance">Points</th>
		</tr>
	</thead>
	<tfoot>
		<tr>
			<th class="logo"></th>
			<th class="name">User</th>
			<th class="balance">Points</th>
		</tr>
	</tfoot>
	<tbody>
	[mycred_users_of_rank rank_id="Beginner" wrap="table" col=3]
	<tr>
		<td class="logo">%rank_logo%</td>
		<td class="name">%user_profile_link%</td>
		<td class="balance">%balance_f%</td>
	</tr>
	[/mycred_users_of_rank]
	</tbody>
</table>