bp_get_activity_parent_user_id

Return the parent activity's user ID.

Description

(bool|int) bp_get_activity_parent_user_id(); 

Returns (bool|int)

False if parent activity can't be found, otherwise the parent activity's user ID.


Usage

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

Defined (1)

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

/bp-activity/bp-activity-template.php  
  1. function bp_get_activity_parent_user_id() { 
  2. global $activities_template; 
  3.  
  4. // Bail if no activity on no item ID. 
  5. if ( empty( $activities_template->activity ) || empty( $activities_template->activity->item_id ) ) { 
  6. return false; 
  7.  
  8. // Get the ID of the parent activity content. 
  9. $parent_id = $activities_template->activity->item_id; 
  10.  
  11. // Bail if no parent item. 
  12. if ( empty( $activities_template->activity_parents[ $parent_id ] ) ) { 
  13. return false; 
  14.  
  15. // Bail if no parent user ID. 
  16. if ( empty( $activities_template->activity_parents[ $parent_id ]->user_id ) ) { 
  17. return false; 
  18.  
  19. $retval = $activities_template->activity_parents[ $parent_id ]->user_id; 
  20.  
  21. /** 
  22. * Filters the activity parent item's user ID. 
  23. * @since 1.7.0 
  24. * @param int $retval ID for the activity parent's user. 
  25. */ 
  26. return (int) apply_filters( 'bp_get_activity_parent_user_id', $retval );