We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 29181
    • 480 Posts
    Has anybody ever created webusers and used the OnWebSaveUser event?

    Let me outline my client’s request, maybe someone has done something similar in the past, and would be willing to offer some advice.

    A manager needs to be able to create a new web user, and ideally when they click on Save, I would like a new web access permission to be created for just this client. Ideally I would like the press of a button to also create a new document which only this person can view (i.e. create a document and assign it this document group).

    Would the OnWebSaveUser event be able to retrieve the value of the new user, or wouldn’t it have been created yet?

    If anyone has done anything like this in the past... I would be very grateful. I’ve never had to create a plugin as yet, and after looking at the documentation, it seems very daunting.

    Thanks for any pointers!
    Taff
      Adrian Lawley: www.adrianlawley.com
      • 29181
      • 480 Posts
      It would appear to be easier than I first thought:

      $e = &$modx->Event;
      global $modx;
      switch ($e->name) {
      
      //if $id is set to 0, it means this user has just been created as opposed to being updated
      
      case "OnBeforeWUsrFormSave":
      if($id==0){
       echo "we need to create a folder";
      }else{
       echo "we can stop right here";
      }
      break;
      }


      I’ll keep this thread updated with my progression.
        Adrian Lawley: www.adrianlawley.com
        • 7455
        • 2,204 Posts
        I did that look here:

        http://modxcms.com/forums/index.php/topic,25087.msg154361.html#msg154361

        read from there I used it with websignup and also works when new webuser is made in the manager
        for now it does not fully work with webloginPE because of missing userid in the array.

        Dimmy
          follow me on twitter: @dimmy01
          • 7231
          • 4,205 Posts
          Web2Manager snippet does this, it could be a starting point: http://www.modxcms.com/Web2Manager-828.html
            [font=Verdana]Shane Sponagle | [wiki] Snippet Call Anatomy | MODx Developer Blog | [nettuts] Working With a Content Management Framework: MODx

            Something is happening here, but you don't know what it is.
            Do you, Mr. Jones? - [bob dylan]
            • 29181
            • 480 Posts
            Thank you both for your replies!

            Dimmy, that looks like just the type of thing I need. I also need to create a document group, a web group (and assign the user I just created to it) then I can use your sql call to create the page (and assign it to this document group).

            I will also need to do some tweaking, but with what I have seen in the Web2Manager snippet, this shouldn’t be so hard after all.

            Thanks guys.

            Taff
              Adrian Lawley: www.adrianlawley.com