bp_activity_screen_single_activity_permalink

Load the page for a single activity item.

Description

bp_activity_screen_single_activity_permalink(); 

Usage

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

Defined (1)

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

/bp-activity/bp-activity-screens.php  
  1. function bp_activity_screen_single_activity_permalink() { 
  2. $bp =buddypress); 
  3.  
  4. // No displayed user or not viewing activity component. 
  5. if ( !bp_is_activity_component() ) 
  6. return false; 
  7.  
  8. if ( ! bp_current_action() || !is_numeric( bp_current_action() ) ) 
  9. return false; 
  10.  
  11. // Get the activity details. 
  12. $activity = bp_activity_get_specific( array( 'activity_ids' => bp_current_action(), 'show_hidden' => true, 'spam' => 'ham_only', ) ); 
  13.  
  14. // 404 if activity does not exist 
  15. if ( empty( $activity['activities'][0] ) || bp_action_variables() ) { 
  16. bp_do_404(); 
  17. return; 
  18.  
  19. } else { 
  20. $activity = $activity['activities'][0]; 
  21.  
  22. // Default access is true. 
  23. $has_access = true; 
  24.  
  25. // If activity is from a group, do an extra cap check. 
  26. if ( isset( $bp->groups->id ) && $activity->component == $bp->groups->id ) { 
  27.  
  28. // Activity is from a group, but groups is currently disabled. 
  29. if ( !bp_is_active( 'groups') ) { 
  30. bp_do_404(); 
  31. return; 
  32.  
  33. // Check to see if the group is not public, if so, check the 
  34. // user has access to see this activity. 
  35. if ( $group = groups_get_group( $activity->item_id ) ) { 
  36.  
  37. // Group is not public. 
  38. if ( 'public' != $group->status ) { 
  39.  
  40. // User is not a member of group. 
  41. if ( !groups_is_user_member( bp_loggedin_user_id(), $group->id ) ) { 
  42. $has_access = false; 
  43.  
  44. // If activity author does not match displayed user, block access. 
  45. if ( true === $has_access && bp_displayed_user_id() !== $activity->user_id ) { 
  46. $has_access = false; 
  47.  
  48. /** 
  49. * Filters the access permission for a single activity view. 
  50. * @since 1.2.0 
  51. * @param array $access Array holding the current $has_access value and current activity item instance. 
  52. */ 
  53. $has_access = apply_filters_ref_array( 'bp_activity_permalink_access', array( $has_access, &$activity ) ); 
  54.  
  55. /** 
  56. * Fires before the loading of a single activity template file. 
  57. * @since 1.2.0 
  58. * @param BP_Activity_Activity $activity Object representing the current activity item being displayed. 
  59. * @param bool $has_access Whether or not the current user has access to view activity. 
  60. */ 
  61.  
  62. // Access is specifically disallowed. 
  63. if ( false === $has_access ) { 
  64.  
  65. // User feedback. 
  66. bp_core_add_message( __( 'You do not have access to this activity.', buddypress ), error ); 
  67.  
  68. // Redirect based on logged in status. 
  69. if ( is_user_logged_in() ) { 
  70.  
  71. } else { 
  72. $url = sprintf( 
  73. site_url( 'wp-login.php?redirect_to=%s' ),  
  74. ); 
  75.  
  76. bp_core_redirect( $url ); 
  77.  
  78. /** 
  79. * Filters the template to load for a single activity screen. 
  80. * @since 1.0.0 
  81. * @param string $template Path to the activity template to load. 
  82. */