Checking s2Member Member Level For Every User in Search Results

Hello everyone,

I have a question that I am sure some of you will find easy to answer.

I am using s2Member with BuddyPress and Geo My WP. In order to be listed on the site, a member has to pay a fee (open registration is off).
When a non-logged in user searches for members it returns a list where each member’s avatar and name contain links to their BP profile.

What I wish to achieve in the search results is this:

  • For members who are level 1: List in search results but member avatar and name contain no links.

  • For members who are level 2 or above: List in search results and member avatar and name contain links.

I have tried the following code in the the search results members loop as a simple test:

`<?php $levelchk = get_user_field(‘s2member_access_level’);
if($levelchk == 1):?>
<?php bp_member_name(); ?>

<?php else: bp_member_name(); endif ?>`

The problem with “$levelchk = get_user_field('s2member_access_level');” is that it returns the level of the user who is currently logged in rather than the user in the search results.

Is there an s2Member function that can check every user’s level in a member’s loop?

Many thanks in advance.

That’s what the [s2Member-List /] shortcode is for. You need the Pro version of s2Member. See https://s2member.com/kb-article/s2member-list-shortcode-documentation/

This shortcode outputs it’s own list of members based on the parameters you pass to it.
My search results already outputs a members list using a php loop.
What i need is a way to probe each members level within this php loop.

OK, try this: http://www.itegritygroup.com/buddypress-members-directory-s2members

But why complicate things? I’d still do this with the [s2Member-List /] shortcode (one for each level) and then prevent hyperlinking using CSS by targeting the appropriate div, like this:

div.ws-plugin--s2member-list-wrapper:nth-child(5)  { 
   pointer-events: none; 
   cursor: default; 
}

Much easier!