Skip to main content

benecaster_resolve_wall_display_name()

Membership Free
benecaster_resolve_wall_display_name( int $user_id, ?object $prefetched = null ): string

Canonical function for resolving the name shown on community surfaces — the Supporter Wall, [benecaster_member_thanks], and any add-on that needs to display a subscriber’s name consistently. Centralises the three-step resolution chain so calling code does not need to read user meta directly:

  1. Wall name (_benecaster_wall_display_name) — the name the subscriber has explicitly
    set for community surfaces.

  2. First + last name — first_name and last_name from WordPress user meta,
    space-joined, when no wall name is set.

  3. WordPress display name (wp_users.display_name) — the final fallback.

Pass a prefetched row object as $prefetched when iterating a result set that already contains the required user fields to skip the extra get_userdata() call per row.

Parameters

Name Type Default Required Description
user_id int — Yes WordPress user ID of the subscriber whose name to resolve.
prefetched object|null null No An object with user fields already loaded (wall_display_name, first_name, last_name, display_name), to avoid a redundant get_userdata() call. Pass null to let the function fetch the user itself. If any expected property is missing the function falls back to fetching the user record.

Return Value

Type: string

The resolved display name. Never empty when the user exists — falls through all three chain steps (wall name → first + last name → WordPress display name) before returning.

Example

// Single lookup
$name = benecaster_resolve_wall_display_name( $user_id );
echo esc_html( $name );

// Bulk render with prefetched rows (avoids extra get_userdata() per row)
foreach ( $subscribers as $row ) {
    $name = benecaster_resolve_wall_display_name( (int) $row->user_id, $row );
    echo esc_html( $name );
}

Notes

The wall name field only appears on the subscriber's account page when the Supporter Wall is enabled on at least one of their shows. A subscriber who has never set a wall name resolves through first/last name or display name.

This function does not fire any filter. To intercept the resolved name for a specific surface, hook into that surface's own output filter (e.g. benecaster_supporter_wall_output).

The wall name is stored separately from wp_users.display_name. Changing a subscriber's wall name has no effect on their WordPress account or any other plugin that reads display_name.

Need this built rather than just documented? See our services →