bp_activity_screen_single_activity_permalink()
Load the page for a single activity item.
Description
Return
(bool|string) Boolean on false or the template for a single activity item on success.
Source
File: bp-activity/screens/permalink.php
102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 | function bp_activity_screen_single_activity_permalink() { // No displayed user or not viewing activity component. if ( ! bp_is_activity_component() ) { return false; } $action = bp_current_action(); if ( ! $action || ! is_numeric ( $action ) ) { return false; } // Get the activity details. $activity = bp_activity_get_specific( array ( 'activity_ids' => $action , 'show_hidden' => true, 'spam' => 'ham_only' , ) ); // 404 if activity does not exist if ( empty ( $activity [ 'activities' ][0] ) || bp_action_variables() ) { bp_do_404(); return ; } else { $activity = $activity [ 'activities' ][0]; } /** * Check user access to the activity item. * * @since BuddyPress 3.0.0 */ $has_access = bp_activity_user_can_read( $activity ); // If activity author does not match displayed user, block access. if ( true === $has_access && bp_displayed_user_id() !== $activity ->user_id ) { $has_access = false; } /** * Fires before the loading of a single activity template file. * * @since BuddyPress 1.2.0 * * @param BP_Activity_Activity $activity Object representing the current activity item being displayed. * @param bool $has_access Whether or not the current user has access to view activity. */ do_action( 'bp_activity_screen_single_activity_permalink' , $activity , $has_access ); // Access is specifically disallowed. if ( false === $has_access ) { // If not logged in, prompt for login. if ( ! is_user_logged_in() ) { bp_core_no_access(); // Redirect away. } else { bp_core_add_message( __( 'You do not have access to this activity.' , 'buddyboss' ), 'error' ); bp_core_redirect( bp_loggedin_user_domain() ); } } /** * Filters the template to load for a single activity screen. * * @since BuddyPress 1.0.0 * * @param string $template Path to the activity template to load. */ $template = apply_filters( 'bp_activity_template_profile_activity_permalink' , 'members/single/activity/permalink' ); // Load the template. bp_core_load_template( $template ); } |
Changelog
Version | Description |
---|---|
BuddyPress 1.2.0 | Introduced. |
Questions?
We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.