Advertisement
sbrajesh

Find Previous/next profile group Id

Mar 12th, 2011
148
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.  
  3. /*custom functions to get next/prev group id*/
  4. //find next group id, return false if current group is last
  5. function custom_get_next_group_id(){
  6. //global $group;
  7. $current_group_id=bp_get_current_profile_group_id();
  8. //get all the groups
  9. $groups = BP_XProfile_Group::get( array( 'fetch_fields' => false ) );
  10. $group_id=false;
  11. foreach($groups as $group){
  12.     if($group->id>$current_group_id){
  13.           $group_id= $group->id;//this is immediate next group
  14.           break;
  15.     }
  16. }
  17. return $group_id;
  18.  
  19. }
  20. //find prev group, 0 if this is first group
  21. function custom_get_prev_group_id(){
  22. //global $group;
  23. $current_group_id=bp_get_current_profile_group_id();
  24. //get all the groups
  25. $groups = BP_XProfile_Group::get( array( 'fetch_fields' => false ) );
  26. //sniff prev group_id
  27. $group_id=0;//which is non existent
  28. foreach($groups as $group){
  29.  
  30.     if($group->id<$current_group_id){
  31.           $group_id= $group->id;//immediate next group is
  32.           continue;
  33.     }
  34. }
  35. return $group_id;
  36. }
  37.  
  38. //get the edit link for a group
  39. function custom_get_group_edit_link($group_id){
  40.     global $bp;
  41.     return $bp->displayed_user->domain . $bp->profile->slug . '/edit/group/' . $group_id;
  42.    
  43.     }
  44.  
  45.  
  46. ?>
Advertisement
Advertisement
Advertisement
RAW Paste Data Copied
Advertisement