Show instructor real name or nickname in group-class views, not the login
CI / Tests (PHP 8.2) (pull_request) Successful in 46s
CI / Tests (PHP 8.1) (pull_request) Successful in 46s
CI / No Debug Code (pull_request) Successful in 2s
CI / PHPStan (pull_request) Successful in 2m47s
CI / Coding Standards (pull_request) Successful in 2m51s
CI / Tests (PHP 8.3) (pull_request) Successful in 2m41s
CI / Build Plugin Zip (pull_request) Skipped

Add Auth\UserName::format(), which prefers a user's first + last name, then
their nickname, avoiding display_name (which can be the login/username).
Route the instructor name through it in both the front-end offerings response
(instructor_name) and the back-end group-class summary and details views.

Tests: composer test (513), composer lint, composer cs all pass.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
This commit is contained in:
2026-07-23 17:50:34 -03:00
co-authored by Claude Opus 4.8
parent b066bef353
commit 87cfe921a9
8 changed files with 136 additions and 20 deletions
+5 -1
View File
@@ -92,7 +92,10 @@ class OfferingEndpointTest extends TestCase
public function testIndexIncludesInstructorNameForEachOffering(): void
{
$instructor = Mockery::mock(\WP_User::class);
$instructor->display_name = 'Ada Lovelace';
$instructor->first_name = 'Ada';
$instructor->last_name = 'Lovelace';
$instructor->nickname = 'ada_login';
$instructor->display_name = 'ada_login';
Functions\when('get_userdata')->justReturn($instructor);
$this->repository->shouldReceive('findAll')->andReturn([$this->group(1, Offering::ACCESS_PUBLIC)]);
@@ -100,6 +103,7 @@ class OfferingEndpointTest extends TestCase
$data = $this->endpoint->index(new \WP_REST_Request())->get_data();
// Real name is shown, not the login-style display name.
self::assertSame('Ada Lovelace', $data[0]['instructor_name']);
}