Changeset 9723 for trunk/src/bp-core/bp-core-catchuri.php
- Timestamp:
- 04/09/2015 03:31:18 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-core/bp-core-catchuri.php
r9664 r9723 259 259 if ( 'members' == $match->key ) { 260 260 261 // Viewing a specific user 262 if ( !empty( $bp_uri[$uri_offset + 1] ) ) { 263 261 $after_member_slug = false; 262 if ( ! empty( $bp_uri[ $uri_offset + 1 ] ) ) { 263 $after_member_slug = $bp_uri[ $uri_offset + 1 ]; 264 } 265 266 // Are we viewing a specific user? 267 if ( $after_member_slug ) { 264 268 // Switch the displayed_user based on compatibility mode 265 269 if ( bp_is_username_compatibility_mode() ) { 266 $bp->displayed_user->id = (int) bp_core_get_userid( urldecode( $ bp_uri[$uri_offset + 1]) );270 $bp->displayed_user->id = (int) bp_core_get_userid( urldecode( $after_member_slug ) ); 267 271 } else { 268 $bp->displayed_user->id = (int) bp_core_get_userid_from_nicename( urldecode( $bp_uri[$uri_offset + 1] ));272 $bp->displayed_user->id = (int) bp_core_get_userid_from_nicename( $after_member_slug ); 269 273 } 270 271 if ( !bp_displayed_user_id() ) { 272 273 // Prevent components from loading their templates 274 $bp->current_component = ''; 275 274 } 275 276 // Is this a member type directory? 277 if ( ! bp_displayed_user_id() && $after_member_slug === apply_filters( 'bp_members_member_type_base', _x( 'type', 'member type URL base', 'buddypress' ) ) && ! empty( $bp_uri[ $uri_offset + 2 ] ) ) { 278 $matched_types = bp_get_member_types( array( 279 'has_directory' => true, 280 'directory_slug' => $bp_uri[ $uri_offset + 2 ], 281 ) ); 282 283 if ( ! empty( $matched_types ) ) { 284 $bp->current_member_type = reset( $matched_types ); 285 unset( $bp_uri[ $uri_offset + 1 ] ); 286 } 287 } 288 289 // If the slug matches neither a member type nor a specific member, 404. 290 if ( ! bp_displayed_user_id() && ! bp_get_current_member_type() && $after_member_slug ) { 291 // Prevent components from loading their templates. 292 $bp->current_component = ''; 293 bp_do_404(); 294 return; 295 } 296 297 // If the displayed user is marked as a spammer, 404 (unless logged-in user is a super admin) 298 if ( bp_displayed_user_id() && bp_is_user_spammer( bp_displayed_user_id() ) ) { 299 if ( bp_current_user_can( 'bp_moderate' ) ) { 300 bp_core_add_message( __( 'This user has been marked as a spammer. Only site admins can view this profile.', 'buddypress' ), 'warning' ); 301 } else { 276 302 bp_do_404(); 277 303 return; 278 304 } 279 280 // If the displayed user is marked as a spammer, 404 (unless logged- 281 // in user is a super admin) 282 if ( bp_displayed_user_id() && bp_is_user_spammer( bp_displayed_user_id() ) ) { 283 if ( bp_current_user_can( 'bp_moderate' ) ) { 284 bp_core_add_message( __( 'This user has been marked as a spammer. Only site admins can view this profile.', 'buddypress' ), 'warning' ); 285 } else { 286 bp_do_404(); 287 return; 288 } 289 } 290 291 // Bump the offset 305 } 306 307 // Bump the offset. 308 if ( bp_displayed_user_id() ) { 292 309 if ( isset( $bp_uri[$uri_offset + 2] ) ) { 293 310 $bp_uri = array_merge( array(), array_slice( $bp_uri, $uri_offset + 2 ) ); … … 299 316 $bp->current_component = ''; 300 317 } 301 302 // Reset the offset 303 $uri_offset = 0;304 }318 } 319 320 // Reset the offset 321 $uri_offset = 0; 305 322 } 306 323 }
Note: See TracChangeset
for help on using the changeset viewer.