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,
info@elgg.org
Security issues should be reported to security@elgg.org!
©2014 the Elgg Foundation
Elgg is a registered trademark of Thematic Networks.
Cover image by RaĆ¼l Utrera is used under Creative Commons license.
Icons by Flaticon and FontAwesome.
- Nikolai Shcherbin@rivervanrain
Nikolai Shcherbin - 1 like
- Hermand Pessek@rheman
Hermand Pessek - 0 likes
- Nikolai Shcherbin@rivervanrain
Nikolai Shcherbin - 1 like
- Hermand Pessek@rheman
Hermand Pessek - 0 likes
- Nikolai Shcherbin@rivervanrain
Nikolai Shcherbin - 0 likes
- Hermand Pessek@rheman
Hermand Pessek - 0 likes
You must log in to post replies.Thanks @RvR.
But I have the same behavior.
defautValTest looks as followed
I Use Elgg developer tools plugin to check that the user's metadata are saved correctly. The metadata pessek_test_default is created but still empty after user account creation.
Regards,
User is a type not an object:
I did it.
But I got the following error.
This should work. Just use return true; at the end
Thanks I found the error. another function was triggered during account creation.
Regards,