List Members on public page by membership type with search capability

I would like to list all paid members by membership type on a public page. For example:

Clicking Membership 1 will list all members of that membership. Clicking Membership 2 will list all members of that membership. But all on a public facing page.

I also want to assign one unique number for every member. Then I want to put search on my website. If someone put this unique number in search then it will display the associated member.

Is this possible with the native Membership 2 API hooks? If so, can you provide some guidance on the code?

  • Adam Czajczyk

    Hello Qaiser Zaidi

    I hope you're well today!

    A full-featured front-end solution like that would require quite a lot of custom coding and as such would be a bit outside the scope of this forum. However, we can provide you with some "foundation" for further development so hopefully it will be of help.

    I have attached a .zip file to this post. The .zip archive contains the "public-members-list.php" file which is an MU-plugin. To use it on your site, please download the file, extract it to your local drive and then upload the "public-members-list.php" file to the "/wp-content/mu-plugins" folder of your site's WP install. If the "mu-plugins" folder doesn't exist inside "wp-content", just create it. There's no need to activate the plugin.

    This will give you two additional shortcodes that you may use on your site.

    First one is: [ms-members-directory-membership] which will display a list of all public membership (it will skip non-public and not published ones). By default, it will only display list of membership names but if you add link="true" attribute, it will print out active links. Handling the links is up to you though (e.g. via additional code in theme).

    So, with a "link" attribute set to true, you would get a HTML output like that:

    <a href="">Membership Name</a>

    In your theme you can then read the value of "ms_directory_membership_id" URL attribute and use it with the second shortcode, which is: [ms-members-directory]

    This shortcode, with no attributes, will display a list of all active members of all memberships. You can add a membership_id="123" attribute (where 123 is an ID of a selected membership) to display only members of that selected membership.

    So, with a bit of additional code on theme level you can put both shortcodes on the same page and display either all members, or, if selected, members of a selected membership (though you'll need to read URL attribute and pass it to the second shortcode).

    All attributes of both shortcodes are described in details in the file that I attached.

    This is a basic solution but should give you a foundation and it can be further developed/extended e.g. to provide paging, to customize CSS, to tweak the type of information about a member etc. That's, however, a subject of further custom development so please feel free to build upon it. If you need additional help with custom coding, please consider posting a question on our "Jobs & Pros" job board here (please note: no WPMU DEV staff involved!) here:

    If you have any additional questions about usage of these provided shortcodes or this specific code that I shared, feel free to ask and I'll be happy to explain.

    Kind regards,

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.