Revision [5084]
This is an old revision of AutomaticUserPageCreation made by DarTar on 2005-01-24 13:42:03.
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.
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
$this->SetUser($this->LoadUser($name));
$this->SetUser($this->LoadUser($name));
$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
}
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
CategoryUserContributions