bp_activity_get_current_context

Gets the current activity context.

Description

(string) bp_activity_get_current_context(); 

The context is the current view type, corresponding roughly to the current component. Use this context to determine which activity actions should be whitelisted for the filter dropdown.

Returns (string)

Activity context. 'member', 'member_groups', 'group', 'activity'.


Usage

  1. if ( !function_exists( 'bp_activity_get_current_context' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'buddypress/bp-activity/bp-activity-functions.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = bp_activity_get_current_context(); 
  7.  

Defined (1)

The function is defined in the following location(s).

/bp-activity/bp-activity-functions.php  
  1. function bp_activity_get_current_context() { 
  2. // On member pages, default to 'member', unless this is a user's Groups activity. 
  3. if ( bp_is_user() ) { 
  4. if ( bp_is_active( 'groups' ) && bp_is_current_action( bp_get_groups_slug() ) ) { 
  5. $context = 'member_groups'; 
  6. } else { 
  7. $context = 'member'; 
  8.  
  9. // On individual group pages, default to 'group'. 
  10. } elseif ( bp_is_active( 'groups' ) && bp_is_group() ) { 
  11. $context = 'group'; 
  12.  
  13. // 'activity' everywhere else. 
  14. } else { 
  15. $context = 'activity'; 
  16.  
  17. return $context;