Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to add a logged in user to a Joomla 2.5 user group?
    primarykey
    data
    text
    <p>When one of our "Registered" users places an order, we have a plugin that successfully adds them to another User Group called "Customer". This works very nicely in the flow of things using <code>JUserHelper::addUserToGroup()</code>.</p> <p>The problem is that even though the user record IS correctly updated, they're already logged in, so they are forced to log out and back in to have the necessary ACL that they need.</p> <p>I've hunted through all the jUser code and docs, and cannot find a way to alter the currently logged in user that is yielded by <code>$user =&amp; JFactory::getUser();</code>.</p> <p>I expect the answer may be obvious to someone who understands the Joomla MVC better than I, but my head is reeling with all the code I've read trying to find a way to accomplish this.</p> <p><strong>UPDATE:</strong></p> <p>Lodder's answer below technically works, but while the "User Groups" ARE actually being updated, the AuthGroups and AuthLevels are not. After my code is run, the $user object DOES show the groups there in, but further down in the object, </p> <pre><code> [_authGroups:protected] =&gt; Array ( [0] =&gt; 1 [1] =&gt; 2 ) [_authLevels:protected] =&gt; Array ( [0] =&gt; 1 [1] =&gt; 1 [2] =&gt; 2 ) </code></pre> <p>There appears to be no way to change this in the current session because it's all protected, and the only place it's updated is in user.php at <code>$identities = $this->getAuthorisedGroups();</code>, which only executes on the first time it's encountered.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload