StoredAuthName

Summary: How to set a stored author name to an authenticated user
Version: 2011-08-05
Prerequisites: AuthUser must be installed
Status: Stable
Maintainer: AntonyTemplier

Question

How can I set automatically a stored author name to an authenticated user?

Answer

For sites with authenticated users with AuthUser, this script allow you to use author name ($Author) stored in the SiteAdmin.AuthUser page and to automatically set the author name in the author field in case it's blank.

It does the same job as you can see at Cookbook:RequireAuthor in automatically setting an author name and, optionally, enforcing author tracking but with stored information.

Installation instruction

  1. You need to install authuser.php before. See the AuthUser page.
  2. Download storedauthname.phpΔ and put it to your /cookbook directory
  3. Add the line below in your local/config.php :
           include_once($FarmD.'cookbook/storedauthname.php');

Usage

To set an author name:

Edit your AuthUser page :

  • Before PmWiki 2.2.0-beta58 : $SiteGroup.AuthUser (usually Site.AuthUser)
  • With and after PmWiki 2.2.0-beta58 : $SiteAdminGroup.AuthUser (usually SiteAdmin.AuthUser)

and add lines like this one:

            userid::authorname

Where userid is $AuthId and authorname is $Author separated by two colons. The script set automatically the author name during edition.

If no author name is found, the author name is set to the user id.

To enforce author tracking for authenticated users, you can set the variable $ForceAuthorTracking in your local/config.php just before the include_once function, like this:

            $ForceAuthorTracking=1; # 1 to enable, 0 (default) to disable
            include_once($FarmD.'cookbook/storedauthname.php');

Notes

Tips

Maybe this recipe can help to manage author tracking in a more convenient way by grouping several ideas found in the cookbook:

What you want

What you do

Leave user to be free to provide an author name.

Nothing

User choice his author name but must provide it.

Add to your local/config.php:

  $EnablePostAuthorRequired = 1;

The author name is set as convenience. A user can change it.

Add to your local/config.php:

  include_once($FarmD.'cookbook/storedauthname.php');

The author name is set automatically and user can't change it.

Add to your local/config.php:

  $ForceAuthorTracking=1;
  include_once($FarmD.'cookbook/storedauthname.php');

Versions

This recipe works with PmWiki >= 2.1.beta20. But for previous version you can change The variable $AuthId with $_SESSION['authid'] in the script storedauthname.php.

  • This recipe was last tested on PmWiki version: 2.2.29
  • This recipe requires at least PmWiki version: 2.1.? and Cookbook:AuthUser
  • This recipe, version 0.1 was installed here the January 10, 2006

Releases

  • January 10, 2006 - v0.1
    First public release. I use it successfully but it has not been tested in a lot of different situations.
  • January 14, 2006 - v0.2
    Fix main condition : users must be authenticated and must be allowed to edit the page for use this script.
  • January 16, 2006 - v0.3
    Fix problems getting user id.
  • June 10, 2011 - v0.4 -> 2011-06-10
    Use $SiteAdminGroup.AuthUser or $SiteGroup.AuthUser if first doesn't exist. Add variable $RecipeInfo for Cookbook:RecipeCheck.
  • August 05, 2011 - v0.5 -> 2011-08-05
    Minor change - Add a break on setting loop to speed up (very very) long users list

Comments

Using pmwiki-2.1.11 (with the default template) and this recipe I found that I had to place the include for authuser before the include for storedauthname. If storedauthname was placed first users would have to login in twice. After first login attempt the user would be shown the login page again.

After I figured that out it appears to be working nicely.

Dale Ray ([(approve links) edit diff]) July 28, 2006

Needs modification for $SiteAdminGroup.AuthUser instead of $SiteGroup.AuthUser for use with recent versions of PmWiki.

 Scott Connard December 01, 2009, at 10:10 PM
This has been updated since version 2011-06-10

See Also

Contributors

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.