-
- 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
-
- 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
-
- 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