Intercept Ajax Query

DescriptionBuddypress snippet by - 11/15/10

This Buddypress snippet is to enable you to add more tabs to the members page, it basically intercepts the ajax query string in an effort to and add some conditionals. The list items on that page for 'All Members' and 'My Friends' have a css id of 'members-all' or 'members-personal'. These become an object and the scope for the query string, so to create a new tab just add a list item with an id of 'members-bands' as in this example. The conditional is run on the query string after broken down and the scope attribute will be 'bands' which is pulled from the id of the list item.

Tags

//Members query switch
function lmc_members_query($members_query){
parse_str($members_query,$query_vars);
switch($query_vars['scope']){
case 'fans':
$members_query .= "&search_terms=Fan Account";
break;
case 'bands':
$members_query .= "&search_terms=Band Account";
break;
case 'venues':
$members_query .= "&search_terms=Venue Account";
break;
default:
return $members_query;
}
return $members_query;
}

//Add the above to your functions.php and then modify the bp loop within whatever area you want, for instance this is the modified version for the members loop:

<?php $members_query = lmc_members_query(bp_ajax_querystring('members'));?>

<?php if (bp_has_members($members_query)) :?>
  • Share
Authored by: Adam J Nowak
http://hyperspatial.com

Comments and Feedback