Note: The recipes here are for PmWiki versions 0.6 and 1.0 only. For PmWiki 2.0 recipes, see Cookbook.


On a site where you want to set password protection on a page-by-page basis, it's handy to know when that protection has been put in place on a particular page. This cookbook item describes how to do so.


Add the following code to your local config.php file.

   $PageHasReadPassword = '';
   $PageHasEditPassword = '';
   $page = ReadPage($pagename);
   if (isset($page['passwdread'])) $PageHasReadPassword = 'readpw set';
   if (isset($page['passwdedit'])) $PageHasEditPassword = 'editpw set';


The two variables can be placed in your site or group .tmpl file wherever you want the flag strings to show up. I put mine at the end of the div that has the search field stuff up at the top ...

    <input class='searchbutton' type='submit' value='Go' /></form>
    <!-- insert flags for passwords -->
    $PageHasReadPassword $PageHasEditPassword</div>

... which puts the little flags right under the search box at the top, visible but not obtrusive.

You can configure the flag strings to whatever you want -- short and cryptic ("RPW," "EPW") or long and verbose ("This page has an edit password set. You will not be able to edit this page without the administrator providing you with a password.")

See Also

Nothing to see here. Move along.


  • 19-May-04 - New.

Comments & Bugs

This solution does not work to show whether the passwords have been set in the config file, only if the page has had the passwords set ad hoc.

If you change the code slightly by adding some if statements, the above bug can be sidestepped:

   $PageHasReadPassword = '';
   $PageHasEditPassword = '';
   $page = ReadPage($pagename);
   if (isset($page['passwdread']) ||
      (isset($DefaultPasswords['read']) && $DefaultPasswords['read'] != '')) {
         $PageHasReadPassword = 'readpw set';
   if (isset($page['passwdedit']) ||
      (isset($DefaultPasswords['edit']) && $DefaultPasswords['edit'] != '')) {
          $PageHasEditPassword = 'editpw set';



  • Profiles/DaveHill asked the question on the PmWiki e-mail list.
  • Pm did all the heavy lifting in figuring out the code (14-May-04)


None, so far as I know ... pmwiki-2.3.7 -- Last modified by {{}}?

from IP: ip should be disabled by default for security reasons