Wiki source for AutomaticUserPageCreation

Show raw source

====Automatic Creation of Userpages on registration====

Based on a request in the SuggestionBox, this code will automatically create the page of a newly registered user. Therefore it uses another page, you can choose, as template.
Code is mostly borrowed from Clonepage-handler (thanks!).

Note that this needs some testing, for example it will surely fail, if you don't give the user the right to load (view?) the template-page.

The user is redirected to WelcomeUser after registration. If you don't want that, just delete the //$this->Redirect(WelcomeUser);// line after inserting the code.

===1. Additions to Wikka.config.php===

add the following to lines to the config-array:
"createuserpage" => "on",
"userpagetemplate" => "YourTemplatePage"

Perhaps you want to change YourTemplatePage to the page which will be the template for the new users.

===2. Changes to actions/usersettings.php===

add after

// log in

$createuserpage = $this->GetConfigValue('createuserpage');
if ($createuserpage == 'on')
$from = $this->GetConfigValue('userpagetemplate');
$note = 'automatic creation';
$thepage=$this->LoadPage($from); # load the source page
if ($thepage) $pagecontent = $thepage['body']; # get its content
$this->SavePage($name, $pagecontent, $note); #create target page

===3. Todo and comments===
- make the note for the creation a config-option (i love having everything configurable ;) --NilsLindenberg
- document
- test a little bit more
- offtopic: urgent note to myself: before registering ten times, should not forget to "comment-in" the code [don't ask ;)]

~& Nils, nice idea - one extra feature I would like to see here is the automatic creation of a main header with the user name, so as to produce something like ##""=====NilsLindenberg=====""## on page creation. This can either be done 'online' during page generation or by preg_replacing a placeholder on the template page. -- DarTar
~~&How about a short "who" action without you are? Do actions work in headers? --NilsLindenberg
~~&I was also thinking that on registration the user should be redirected //either// to his/her own new page, or to WelcomeUser which could have a dynamic //link// to the current user's page. --JavaWoman
~~~&Yes, I definitely agree that on registration, the user should be redirected to WelcomeUser (which might also contain a dynamic welcome message like: Hi, {{who}}). -- DarTar
~~~~&DarTar, Eggzakly! :) -- JavaWoman
~~~&Well, this is the case now. Except from the dynamic message. That is something the admin of a wiki has to/can do :) --NilsLindenberg
~~~~&Nils, look at the **code** DarTar used here - one of the "little actions" is all that's needed - which will quite likely be included in the //next// version (after Wikka release :) -- JavaWoman
~~~~~&I know that. But it is to the admin of a wiki, if he includes such thing into the template-page, or not. Not of the user-registration :) --NilsLindenberg
~~~~~~&Oh, I see what you mean now, Nils. The idea was to include such a "dynamic welcome" in the WelcomeUser page though - where it would be just the action. But then we'd have to create such a page on an install - for now it's only here... Hmmm. --JavaWoman

Valid XHTML :: Valid CSS: :: Powered by WikkaWiki