Adding Custom Information to your Member Search Results
Ever wanted to add specific information to members depending on :
1. If User is logged in (Is a member)
2. If Member is of a Specific Membership Level
3. If Member is able to see extra information from other members (Premium Members or Higher Level Member)
For all of these cases, we can take the necessary steps to make our search results adapt to our needs. So follow this small tutorial to accomplish any of the points mentioned above:
1. On your Dashboard, go to Content - Edit post settings.
2. Select the Listing Feature and click on Edit
3. On your Listing Feature edit page, go to the Search Results Design Section.
4. Once on this section, find the text area that says Page Loop.
5. In the code look around line 34 you should see the following: <table class="bmargin">, below this code you can start adding and ordering the code you want so it shows on the search results.
6. So for this example we will be using this part of the original Listing code and inserting our custom code in it:
SHOWING CUSTOM CODE DEPENDING ON THE MEMBERSHIP LEVEL OF THE USER SHOWN IN THE SEARCH RESULTS
So let's add our first custom code that will show some text only if the member in the search result is of a certain membership level, for this example, the membership level will be 1 and the custom code will be:
<?php if ($user[subscription_id] == '1') { echo "CONGRATULATIONS!! You are an awesome gnarly member from Membership Level 1. Cowabunga!"; } else { echo "This text shows if member is not from membership level 1"; } ?>
We will add the above code below line 34 which has the <table class="bmargin"> code in it, so the end result should look like this:
<table class="bmargin"> <?php if ($user[subscription_id] == '1') { echo "CONGRATULATIONS!! You are an awesome gnarly member from Membership Level 1. Cowabunga!"; } else { echo "This text shows if member is not from membership level 1"; } ?> <?php if ($user_data[company] != "" && $user_data[listing_type] == "Individual") { ?> <tr class="hidden-xs"> <td class="bold text-right rpad hidden-xs"><?php echo $Label[company_label2]?>:</td> <td><?php echo $user_data[company]?></td> </tr> <?php }
After saving this, the visual output of the search results will now look like this:
SHOWING CUSTOM CODE DEPENDING ON THE MEMBERSHIP LEVEL OF THE USER THAT IS VIEWING THE SEARCH RESULTS
So let's say that you want to show the text, not depending on the membership level of the users in the search results, but instead, of the membership level of the user that is viewing the webpage. For this case we would only change the code a bit like this:
<table class="bmargin"> <?php <?php if ($_COOKIE[subscription_id] == '1') { echo "CONGRATULATIONS!! You are an awesome gnarly member from Membership Level 1. Cowabunga!"; } else { echo "This text shows if member is not from membership level 1"; } ?> <? if ($user_data[company]!="" && $user_data[listing_type]=="Individual") { ?> <tr> <td class="bold text-right rpad hidden-xs"><?=$Label[company_label]?>:</td>
As you can see, we only changed the IF statement from
if ($user[subscription_id] == '1') {
to
if ($_COOKIE[subscription_id] == '1') {
which would make the code, instead of checking the user in the search results if he/she is from membership level 1, it would check the user who is viewing the site. The end result would be something like:
SHOWING CUSTOM CODE DEPENDING ON THE MEMBERSHIP LEVEL OF THE USER THAT IS VIEWING THE SEARCH RESULTS AND THE USER SHOWN IN THE SEARCH RESULTS
For this stage, we are now combining both, the check to see who is viewing the site and the check to see what membership level the user shown in the search results is. So let's create our scenario. Let us say we wanted for Members of membership level 1 (Premium Members) to see extra information from Membership Level 2 members and even more information from Membership Level 3 members. The end code would be something like this:
<?php if ($_COOKIE[subscription_id] == '1' && $user[subscription_id] == '2') { echo "This text will ONLY show if the member viewing the page is level 1 and the member in the search result is level 2."; } else if ($_COOKIE[subscription_id] == '1' && $user[subscription_id] == '3') { echo "This EXTRA text will ONLY show if the member viewing the page is level 1 and the member in the search result is level 3."; } else { echo "This text shows if member in results is not 2 or 3"; } ?>
So if the user viewing the page is NOT a membership level 1, the search results would show like this:
But if the member viewing the site has a membership level of 1, then it would look like this:
With this guide, you have now learned how to do 3 types of customization to your search results. You can add extra information of any kind for each member and adapt the information as you see fit to provide better services for your members.