automatic wiki page creation with default data during user registration

mmln
Joined: 22 Jun 2008

automatic wiki page creation with default data during user registration

Posted:04 Jul 2008 (11:19 UTC)
I need to create a wiki page for each user with default data upon registration, so I am changing to the regiser.php to call wiki/bitpage->store() function.

Default data for wiki is title=username..rest of the field can be default or blank.

i tried with below code

require_once( WIKI_PKG_PATH.'BitPage.php' );
require_once( WIKI_PKG_PATH.'BitBook.php' );

$wikiParams = array(
'user_id' => $userId
'title' => $userid );

$gContent ->Store($wikiParams);

getting error

Fatal error: Call to a member function Store() on a non-object

anybody can help ?
Will
Joined: 28 Sep 2005

Re: automatic wiki page creation with default data during user registration

Posted:05 Jul 2008 (13:42 UTC)
are you aware that the users package already creates pages for each user. they're not exactly wiki pages. but very similar.
Will
Joined: 28 Sep 2005

Re: automatic wiki page creation with default data during user registration

Posted:05 Jul 2008 (14:53 UTC)
To answer your question about your error.

You have included the class files for a wiki page:
require_once( WIKI_PKG_PATH.'BitPage.php' );

(note: you dont need the book one, since you are not trying to create a book object here.)

Now you need to create an instance of the page class so you can access the methods. like so:

$userPage = new BitPage();

now you can operate on it. you dont want to operate on gContent in this case, as IIRC the new user account is probably the gContent object - if there is one at all. You're going to use your $userPage instance.

$userPage ->store($wikiParams);

Also php is case sensitive, so that's store, small 's', not Store.
mmln
Joined: 22 Jun 2008

Re: automatic wiki page creation with default data during user registration

Posted:08 Jul 2008 (04:23 UTC)
Will,
Appreciate your prompt response. It did solve my problem of creating default wiki page.
I have few questions though (:mrgreen:)

1) In paramaters I am passing the value for the field data, however only userId and title informatio is used to create a new wiki page, it is missing the value passed to 'data' field.

$wikiParams = array(
'user_id' => $userId
'title' => $userid
'data' =>"Home Page for".$userId);

2) You mentioned about user page doing something similar, can you point to me the right function ?

3) If I have to extend the wiki page I have created to set some permissions so that each user(i.e. user group only can change not other groups)

can I include as below..doesn't seem to be working.

require_once( LIBERTY_PKG_PATH.'LibertyContent.php' );

$contPerm = new $LibertyContent
$contPerm = $LibertyContent -> storePermission( group_id, "p_wiki_edit_page",FALSE, NULL );
mmln
Joined: 22 Jun 2008

Re: automatic wiki page creation with default data during user registration

Posted:09 Jul 2008 (01:40 UTC)
Content permission issue is resolved after correctign the syntax
($contPerm -> storePermission( $group_id, "p_wiki_edit_page",FALSE, NULL );

I still have issue (1)
and one more question, is there any easy way to retrieve the contentId of wiki page that was created.
  Page 1 of 1  1