PageCreator

Summary: adds page creator (original author) to be stored as a page attribute
Version: 2008-02-24
Prerequisites:
Status:
Maintainer:
Discussion: PageCreator-Talk?

Questions answered by this recipe

How can I set and safely store the name of the original page author or page creator?

Description

Adding the code below will give you:

  • an extra page attribute cauthor, which is set automatically or with ?action=attr.
  • a field in the page attributes edit form, in which Page created by can be set.
  • a page variable {$CreatedBy} which can be used in wiki pages.
  • an extra edit function, which sets cauthor with the author name (if present) when a new page is saved .

Add the following to config.php, or include within an add-on php script:

# add cauthor to page attributes as extra field for ?action=attr
$PageAttributes['cauthor'] = '$[Page created by:]';

# add page variable {$CreatedBy} 
$FmtPV['$CreatedBy'] = '@$page["cauthor"]';

# automatically set page creator to $Author for every new page
function SetPageCreator($pagename, &$page, &$new) {
	global $EnablePost, $Author, $PageCreator, $Now;
	SDV($PageCreator, $Author);
	if ($EnablePost && !$new["author"])
		$new["cauthor"] = $PageCreator; 
}
array_unshift($EditFunctions, 'SetPageCreator');

Notes

Release Notes

If the recipe has multiple releases, then release notes can be placed here. Note that it's often easier for people to work with "release dates" instead of "version numbers".

See Also

Contributors

Comments

See discussion at PageCreator-Talk?

User notes? : If you use, used or reviewed this recipe, you can add your name. These statistics appear in the Cookbook listings and will help newcomers browsing through the wiki.