We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 39410
    • 2 Posts
    Is there a simple way to let the user choose to deactivate themselve via a buton in the frontend?
      • 3749
      • 24,544 Posts
      If you process a form and execute this code on submission, the user should be deactivated:


      /* only works for logged in users */
      if ($modx->user->hasSessionContext($modx->context->get('key) ) ) {
          $modx->user->set('active', 0);
          $modx->user->save();
      }



      That won't delete the user record, it will just mark the user as inactive and he or she won't be able to log in. Also, the user will still be logged in unless you explicitly log them out.


      ------------------------------------------------------------------------------------------
      PLEASE, PLEASE specify the version of MODX you are using.
      MODX info for everyone: http://bobsguides.com/modx.html [ed. note: BobRay last edited this post 14 years, 5 months ago.]
        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