Add more fields to core Member on SS 6

Silverstripe Version: 6

Question:

How can I add more fields to Member? I tried with custom extension:

src/Extension/MyMemberExtension.php

<?php

declare(strict_types=1);

//use SilverStripe\ORM\DataExtension;

namespace App\Extension;

use SilverStripe\Core\Extension;

class MyMemberExtension extends Extension
{
    private static array $db = [
        'Jwt' => 'Varchar(20)',
    ];

    public function getName2()
    {
        return $this->FirstName . ' ' . $this->LastName;
    }
}

Obviously I tried the “docs” way

And my YML in _config/extensions.yml

\SilverStripe\Security\Member:
  extensions:
    - App\Extension\MyMemberExtension

I assume by “field” you mean both a database column (which you have already done) and a form field which seems to be what you’re missing.

For that you can implement the updateCMSFields() extension hook as described in the scaffolding fields docs and no doubt in various other parts of the docs as well.

Null rightly pointed out in the public slack that this should be
SilverStripe\Security\Member: (i.e. remove the first \)

That was it! Thanks.