It's better when it's simple

User Tools

Site Tools


My first attempt at hacking DokuWiki, and only my second attempt at hacking PHP, so apologies for any rough edges or bad coding practices!

I ( l u r c h (at) d u r g e (dot) o r g ) wanted to be able to filter the list of recent changes by username (the wiki installation I've setup is only accessible by registered users), and I found it surprisingly easy :-)

The instructions below were written for dokuwiki 2008-05-05. I've created a new page with instructions for dokuwiki 2009-02-14.
  1. Edit inc/changelog.php and update function _handleRecent to support filtering by user. Change
    function _handleRecent($line,$ns,$flags){


    function _handleRecent($line,$ns,$flags,$user){

    and then inside the function just before

      // filter namespace

    add the following two lines

      // filter user
      if (($user) && ($recent['user'] != $user)) return false;
  2. Still in inc/changelog.php, update function getRecents to support (optional) filtering by user. Change
    function getRecents($first,$num,$ns='',$flags=0){


    function getRecents($first,$num,$ns='',$flags=0,$user=''){

    and then change

    $rec = _handleRecent($lines[$i], $ns, $flags);


    $rec = _handleRecent($lines[$i], $ns, $flags, $user);
  3. Now we need to edit inc/html.php. Find function html_recent and then just after the line that says global $ID; add the following
    $user = isset($_REQUEST['user']) ? $_REQUEST['user'] : null;

    Then scroll down a few lines and change both the getRecents lines to say

    $recents = getRecents($first,$conf['recent'] + 1,getNS($ID),0,$user);

    (i.e. append ,0,$user to the argument lists)

That's it! Now you can filter the list of recent changes page by appending a user=<username> parameter to the URL e.g. ?do=recent&user=myusername to show just changes by myusername. Without any user parameter specified, it displays recent changes by all users, just as before.

tips/recent_changes_by_user.txt · Last modified: 2009-02-19 01:03 by

Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 4.0 International
CC Attribution-Share Alike 4.0 International Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki