Why my custom Metadata is empty ?

Hi everyone,

I am trying to create a custom user's metadata with a default value after user account creation.

So in the init of the my  Bootstrap.php I have the following entry.

public function init() {

          $this->elgg()->events->registerHandler('create', 'user', '\Pessek\PessekClasses\PesseConfig::defautValTest');

}

defautValTest looks as followed.

 

public static function defautValTest(Event $event) {

    

$user = $event->getObject();


if (!$user instanceof \ElggUser){

        return;

}


elgg_call(ELGG_IGNORE_ACCESS, function () use ($user) {

        $user->pessek_test_default = "123456789";

});


}

Every time a new user is created,  my function is triggered. But pessek_test_default is empty.

I Use Elgg developer tools plugin to check that the user's metadata are saved correctly. The metadata pessek_test_default is empty after user account creation.

What's wrong in my code ?

Regards,

 

 

 

Beginning Developers

Beginning Developers

This space is for newcomers, who wish to build a new plugin or to customize an existing one to their liking