We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 36624
    • 535 Posts
    Hello,

    When my users edit their profile on the front-end i would like to give them the ability to desactivate (set active = 0) their profile.
    Actually they have a button to delete their profile with a snippet like this and it works well :
    if ($user = $modx->getObject('modUser', $modx->getLoginUserID('web'))) {
        $user->remove();
    // works, user is deleted.
    }
    


    So..
    For the desactivation i have tried this :

    if ($user = $modx->getObject('modUser', $modx->getLoginUserID('web'))) {
    	
        $user->set('active',0);
       // but this don't work at all.. ???
    }
    


    i can't figured why.

    i even tried this without luck :

    $userId = $modx->getObject('modUser', 51); // 51 is a user with active set to 1 
    $userId->set('active',0);
    


    I don't know what to do next .. please help me.

    This question has been answered by BobRay. See the first response.

      CTRL+SHIFT+U - Clear Cache
      CTRL+SHIFT+H - Hiding Heft Panel
      CTRL+SHIFT+N - Fast Create Resource
      CTRL+ALT+P - Preview Recource (in edit resorce window)
      CTRL+ALT+S - Save
    • discuss.answer
      • 3749
      • 24,544 Posts
      $user->save();


      wink
        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
        • 36624
        • 535 Posts
        Quote from: BobRay at Nov 13, 2014, 04:58 AM
        $user->save();


        wink

        Thank you Bob.
          CTRL+SHIFT+U - Clear Cache
          CTRL+SHIFT+H - Hiding Heft Panel
          CTRL+SHIFT+N - Fast Create Resource
          CTRL+ALT+P - Preview Recource (in edit resorce window)
          CTRL+ALT+S - Save
          • 36624
          • 535 Posts
          btw, do you know where to find a complete list actions for users api ?
          As a noobi dev i need DOCS and littles simples codes..

          i actually know :

          $user->get();
          $user->set();
          $user->remove();
          $user->save();
          


          is there more ?
            CTRL+SHIFT+U - Clear Cache
            CTRL+SHIFT+H - Hiding Heft Panel
            CTRL+SHIFT+N - Fast Create Resource
            CTRL+ALT+P - Preview Recource (in edit resorce window)
            CTRL+ALT+S - Save
            • 3749
            • 24,544 Posts
            A quick regex search of the modUser class file produced this, though other methods are inherited via xPDO:

            function set
            function setSudo
            function save
            function remove
            function loadAttributes
            function isAuthenticated
            function endSession
            function passwordMatches
            function activatePassword
            function changePassword
            function getSessionContexts
            function addSessionContext
            function generateToken
            function getUserToken
            function removeSessionContext
            function removeSessionContextVars
            function removeSessionCookie
            function hasSessionContext
            function countMessages
            function getSettings
            function getResourceGroups
            function getUserGroups
            function getPrimaryGroup
            function getUserGroupNames
            function isMember
            function joinGroup
            function leaveGroup
            function removeLocks
            function generatePassword
            function sendEmail
            function getDashboard


              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
              • 36624
              • 535 Posts
              Thank you Bob. I'm just sad you need to make some magic to see functions..

              omg i love modx but the lack of docs is going to kill me.

              *sic*
                CTRL+SHIFT+U - Clear Cache
                CTRL+SHIFT+H - Hiding Heft Panel
                CTRL+SHIFT+N - Fast Create Resource
                CTRL+ALT+P - Preview Recource (in edit resorce window)
                CTRL+ALT+S - Save
                • 3749
                • 24,544 Posts
                  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