[Pmwiki-users] how can I change the page author attribution?

Patrick R. Michaud pmichaud
Wed Dec 8 20:23:10 CST 2004


On Wed, Dec 08, 2004 at 06:14:32PM -0500, Neil Herber wrote:
> 
> At 2004-12-08  02:58 PM -0700, Patrick R. Michaud is rumored to have said:
> 
> Geez, I'm feeling less intelligent than my users because your explanation 
> is not clear to me. Are there cookbook recipes that explain how to "do a 
> mapping in config.php" or set up the author name selector? Otherwise I 
> don't have a clue where to start.

Sorry, didn't mean to confuse the issue further (which I likely did).
While the cookbook is supposed to be the place where we describe all
of the wonderful things that can be done, it's unfortunately far from
complete.

Essentially, if you set a value for $Author in config.php it will
override any value that an author might have placed in the edit form,
and you can use arbitrarily complex code to do that.  So, if you
wanted to make sure that any author name beginning with "Charles" or
"Chuck" mapped to "Charles Brown", you could do:

   if (substr(@$_REQUEST['author'], 0, 7) == 'Charles')
     $Author = 'Charles Brown';
   if (substr(@$_REQUEST['author'], 0, 5) == 'Chuck')
     $Author = 'Charles Brown';

As a more common example, to set the author name to the username
provided by HTTP authentication (e.g., authentication via an Apache 
.htpasswd file), you can do:

   $Author = @$_SERVER['REMOTE_USER'];

Or, to have "real names" instead of login names used, it helps to 
have an array:

   $AuthorNames = array(
     'pmichaud' => 'Patrick Michaud',
     'jr' => 'John Rankin',
     'chr' => 'Christian Ridderstr?m',
     'duff' => 'Scott Duff');
   $Author = $AuthorNames[@$_SERVER['REMOTE_USER']];

Pm



More information about the pmwiki-users mailing list