[pmwiki-users] How to use author name in if statement

John W Morris johnwmorris at peak.org
Sun Aug 14 23:28:33 CDT 2005


Goal... display something based on a login name/password combo. Author name actually.  It will be used on internal sections of a page and on sections of the main menu.
I think I almost have it... in massively ugly form, to be sure (code at page bottom)... but I need help.

The loginlogout script seems fine.
UserAuth seems to work fine.
The Author field in the edit window is populated from the login
But...
The following conditional only works if I enter the author name "guest" from the edit window.  If I enter "guest" and "member" from the login form... nada.
(I have a little {$Author} nearby on the page and it is merrily telling me "guest". Lying little devil!)

(:if author guest:)%red%Guest access only....


--------------------------------------------------------------------------------

The following code forces even the admin to enter their name.  I like what it does, but something is wrong with how Author gets filled.... or not filled.

include_once("$FarmD/cookbook/loginlogout.php");

$DefaultPasswords['admin'] = 'id:admin';
$DefaultPasswords['edit'] = 'id:editor';

$EnablePostAuthorRequired = 1;
##
$AuthUser['admin'] = crypt('adminword');
$AuthUser['editor'] = crypt('editorword');
$AuthUser['seamus'] = crypt('password');
$AuthUser['guest'] = crypt('member');
##
include_once("$FarmD/scripts/authuser.php");
## If no $Author is set, set it to the authenticated user name
if ($action == 'edit' && !@$_COOKIE['author']) {
   @session_start();
   if (@$_SESSION['authid']) {
     $Author=@$_SESSION['authid'];
     setcookie('author',$Author,0,'/');
   }
}
## set 'author' for 'if' statements condition
$Conditions['author'] = "\$GLOBALS['Author']==\$condparm";
-------------- next part --------------
An HTML attachment was scrubbed...
URL: /pipermail/pmwiki-users/attachments/20050814/ce733c55/attachment.html 


More information about the pmwiki-users mailing list