WordPress.org

Making WordPress.org

Changeset 10589


Ignore:
Timestamp:
01/18/2021 02:27:18 AM (4 months ago)
Author:
dd32
Message:

User Tweaks: Avoid some PHP Notices in the BuddyPress code, as the displayed user functions may be called with no displayed user.

See [10588], [10586].
See #5578.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/mu-plugins/pub/wporg-user-tweaks.php

    r10588 r10589  
    4444 */
    4545add_filter( 'bp_displayed_user_fullname', function( $name ) {
    46     if ( '' === $name ) {
    47         $name = buddypress()->displayed_user->userdata->user_nicename;
     46    $userdata = buddypress()->displayed_user->userdata;
     47
     48    if ( ! $userdata ) {
     49        return $name;
    4850    }
    4951
    50     $name = maybe_replace_blocked_user_name( $name, buddypress()->displayed_user );
     52    if ( '' === $name ) {
     53        $name = $userdata->user_nicename;
     54    }
     55
     56    $name = maybe_replace_blocked_user_name( $name, $userdata );
    5157
    5258    return $name;
Note: See TracChangeset for help on using the changeset viewer.