Changeset 10586
- Timestamp:
- 01/15/2021 06:14:21 AM (2 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/mu-plugins/pub/wporg-user-tweaks.php
r10585 r10586 41 41 42 42 /** 43 * Filter the BuddyPress displayed name. 44 */ 45 add_filter( 'bp_displayed_user_fullname', function( $name ) { 46 if ( '' === $name ) { 47 buddypress()->displayed_user->user_nicename; 48 } 49 50 $name = maybe_replace_blocked_user_name( $name, buddypress()->displayed_user ); 51 52 return $name; 53 } ); 54 55 /** 43 56 * Some users have an empty display_name field, which shouldn't happen, but does due to sanitization. 44 57 * … … 62 75 */ 63 76 function maybe_replace_blocked_user_name( $name, $user ) { 64 if ( ! defined( 'WPORG_SUPPORT_FORUMS_BLOGID' ) ) { 77 if ( ! ( $user instanceof WP_User ) ) { 78 if ( ! empty( $user->ID ) ) { 79 $user_id = $user->ID; 80 } elseif ( !empty( $user->id ) ) { 81 $user_id = $user->id; 82 } else { 83 $user_id = $user; 84 } 85 86 $user = get_user_by( 'id', $user_id ); 87 } 88 89 if ( ! $user || ! $user->exists() ) { 65 90 return $name; 66 91 } 67 92 68 $user_id = is_object( $user ) ? $user->ID : $user;69 if ( ! $user_id) {70 return $ name;93 // If it's a recently blocked user, it'll have a broken user_pass, use that. 94 if ( 'BLOCKED' === substr( $user->user_pass, 0, 7 ) ) { 95 return $user->user_nicename; 71 96 } 72 97 73 if ( ! ( $user instanceof WP_User) ) {74 $user = get_user_by( 'id', $user);98 if ( defined( 'WPORG_SUPPORT_FORUMS_BLOGID' ) ) { 99 $user->for_site( WPORG_SUPPORT_FORUMS_BLOGID ); 75 100 } 76 101 77 if ( ! $user ) { 78 return $name; 79 } 80 81 $user->for_site( WPORG_SUPPORT_FORUMS_BLOGID ); 82 83 /* Cannot use $user->has_cap( 'bbp_blocked' ), as we may be within a capability filter. */ 84 if ( !empty( $user->roles ) && in_array( 'bbp_blocked', $user->roles ) ) { 102 // Cannot use $user->has_cap( 'bbp_blocked' ), as we may be within a capability filter. 103 // Only works on the WordPress.org network. 104 if ( ! empty( $user->roles ) && in_array( 'bbp_blocked', $user->roles ) ) { 85 105 return $user->user_nicename; 86 106 }
Note: See TracChangeset
for help on using the changeset viewer.