everybody! Could you please help me with the following problem.
Kunena 4.0.1. I have created several special user ranks. Some users have a permission to create new users. The task is to set rank of the new user differ to the default value but one of the special ranks. I've tried to do it using a custom plugin related to the "onUserAfterSave" event. But it didn't work. What I’m doing wrong?
function onUserAfterSave ($user, $isnew)
{
if ($isnew)
{
$NewKUser = KunenaFactory::getUser(intval($user['id']));
$NewKUser->rank['rank_id'] = 11;
$NewKUser->save(true);
}
}
Also I got another solution, a one liner code but you need to edit existing plugin. So when a user registers in joomla, then it will be automatically assigned a rank.
For that you need to edit the kunena system plugin, which you can find at
plugins->system->kunena
. if you openkunena.php
you will find a functionChange it or modify it by adding a single line
$kuser->rank
Also its better to create a copy of that plugin before editing.