This nifty little shortcode will output the number of members in a level (or across all levels).

The output displays a message in the format: “This site has 25 Gold members”, or you can define the attribute ‘justnumber’ to output only the count of members and craft your own message like the one pictured to the right.


Shortcode Attributes

  • justnumber: Show just the count of members (optional; default: NULL)
  • level: A single level ID or comma-separated list of level IDs (optional; default: count for all levels)
  • status: A single status or comma-separated list of statuses (optional; default: ‘active’)

pmpro_member_number

The Shortcode Plugin

This code recipe requires a PMPro Plus Account or higher.

View Membership Options


Comments (9)

Author’s gravatar

“defining attribute” justmember means [pmpro_member_count justmember=true]

Reply
Author’s gravatar

level as a comma delimited list doesn’t work. I tried
[pmpro_member_count level=1,2,3,5] and
[pmpro_member_count level=”1,2,3,5″]

Reply
Author’s gravatar

I was going to add this to the plugin/gist for you, but it gets complicated generating the text “This site has %s members”. If you wanted to update yours to do this, you could do something like:

$levels = array_map(‘trim’, explode(‘,’, $attrs[‘level’]));

And then update

AND `membership_id` = ” . intval($attrs[‘level’]);

to be

AND `membership_id` IN(” . $levels . “)”;

Reply
Author’s gravatar

Hi, Could this be used to count members who have bought access to a single page using the “Purchase Access to a Single Page or Post” Add On?

Reply
Author’s gravatar

The SQL would have to be changed to count the data we store in post meta and user meta. If you post to our member forums and mention that I sent you, we can work on that for you.

Reply

Leave a Reply

Your email address will not be published. Required fields are marked *