We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 36695
    • 47 Posts
    I’m using the code below to add a user to a specific user group (which may or not be the best way of doing it...). This happens whilst the user is logged in. However, the new permissions don’t take effect until I flush sessions through the manager. Can I do that using the api? i.e. After the code below successfully completes, can I do something like $modx->flushMySessionDataButDontLogMeOut()?? (I have been rtfm-ing for longer that I care to add up btw...)

    Code to add the user to the user group:
    $assign = $this->modx->newObject('modUserGroupMember');
    	  $data = array('user_group'=>$groupid,'member'=>$userid,'role'=>1);
    	  $assign->fromArray($data);
    	  $assign->save();
    


    Thanks in advance
      • 3749
      • 24,544 Posts
      The Flush permissions menu item executes this JS code:

      MODx.msg.confirm({
          title: _('flush_access')
          ,text: _('flush_access_confirm')
          ,url: MODx.config.connectors_url+'security/access/index.php'
          ,params: {
              action: 'flush'
          }
          ,listeners: {
              'success': {fn:function() { location.href = './'; },scope:this}
          }
      });


      That might get you started.
        Did I help you? Buy me a beer
        Get my Book: MODX:The Official Guide
        MODX info for everyone: http://bobsguides.com/modx.html
        My MODX Extras
        Bob's Guides is now hosted at A2 MODX Hosting