Member Search Page code

Hi guys.

I am trying to find the right shortcodes for S2Member Pro to achieve my goal for a member search page. My requirement is not straight out of the knowledge base options and my knowledge of shortcodes is very limited, hence my question here asking for help!

I am creating a search facility for ex-pupils of a school to find friends. I have asked in a custom field for permission to share a member details with other members, in case they don’t want to, so I want a function which can display all members who have chosen to share their details, then with a search box allow them to search and display by last name, year of leaving the school, or country of residence,

I am stuck, but have the following:-

[s2Member-List-Search-Box /]

[s2Member-List enable_list_search=“yes” / s2member_custom_field_searching / orderby=“last_name” order=“ASC” / show_fields=“leaving_year,Country,email” / ]

The problems are:-

  1. how to only allow a person to be searched and included if a custom Boolean field is a “1”.
  2. the fact that with this code the list orders by last name correctly unless any search criteria are entered, when the “last name” order is ignored.

Grateful for any help in solving these two issues!

Many thanks
Andy

Take a look at this: https://s2member.com/using-the-s2member-list-shortcode/

Hi Tim. That helped a lot with neatening it up, but the key thing I can’t seem to make work is only including members in the list who meet a custom field criteria. Can anyone help me to limit the output to only those members who have agreed to share their details, to be included in the output. That custom field is “sharing” and I have the following code currently with the option highlighted in bold that does not work. Also, it still doesn’t output in last_name order!:-

[s2Member-List-Search-Box placeholder=“Try surname, leaving year or Country of Residence” /]

[php] if(!empty($_REQUEST[‘s2-s’])): [/php]

[s2Member-List enable_list_search=“yes” **s2member_custom_field_sharing=“1”** orderby=“last_name” order=“ASC” exclude="" show_fields=“leaving_year,Country,email” limit=“5” /]

[php] endif; [/php]

Thanks in advance!
Andy

You need to make use of the exclude attribute to exclude those who haven’t opted to be amenable to being searched.

At the moment, you have set it to nothing, whereas it needs to contains the IDs of those to exclude. (If there are many such members, you will need to write a PHP function to identify them automatically for the purposes of the shortcode.)

Thanks Tim. I shall see whether I can investigate how to do a PhP function to do an exclude check on all members.

Hi I’m trying to do the same thing, but it appears that the exclude function does not work with the search function. I’ve excluded a list of IDs but they are ignored, Is there any knowledge of this?

Thanks