Downloads: Getting DokuWiki to use Wordpress Authentication (v1.2)
This extension does not transform your Wordpress (WP) posts into DokuWiki (DW) entires. If your looking for that functionality, I’d recommend doing a google search for dwBliki plugin.
What this extension does is to get DokuWiki to use Wordpress’ authentication, i.e. DokuWiki to use Wordpress’ user database, using an authentication plugin for DokuWiki.
Download the DokuWiki Authentication Extension (v1.2)
Previous downloads:Download the DokuWiki Authentication Extension (v1.1) and Download the DokuWiki Authentication Extension
Before you begin, you’ll need to be able to run MySQL commands on your WP database and shouldn’t be afraid of modifying some code.
Much of this work was based on the DW splitbrain.org wiki documentation. I used the phpbb integration as a template. See:
http://wiki.splitbrain.org/wiki:auth:mysql
http://wiki.splitbrain.org/wiki:tips:integrate_with_phpbb
I’ve tested this with versions:
DokuWiki: 2006-03-09d
Wordpress: 2.0.4
I can’t speak for other versions.
Version History
1.2 (10/10/2006)
- The extension turns back on “magic quotes” which causes additional slashes in DW articles after editing.
1.1 (03/10/2006)
- Small fix for using Wordpress tags while logged in.
- Documentation/Instructions updates
1.0 (27/09/2006)
- First Release
Notes on using this authentication plugin
I’d recommend that you get your users to use the WP’s Register, Login and Logout interface rather than DW’s. However, DW’s Login and Logout should work fine and they should log in and out of WP at the same time.
BUT you should use WP to add new users. If you use DW, they won’t be configured correctly to use WP as you need to modify two SQL tables and DW will only modify one.
By default all users are a member of the “defaultgroup”. WP does not have any concept of user groups. It does have a concept of roles which I have ignored because I wanted the flexibility of DW’s user groups. You can’t really remove users from this group unless you modify “wordpress.class.php”.
You can use DW’s “User Manager” to add and remove your WP users from DW’s user groups but avoid the “Configuration Settings” as this overwrites your local.php and seems to cause problems for the WP authenication.
This plugin also introduces a useful feature. Because it pulls in your Wordpress files, you can then, anywhere else in DW, access Wordpress functions. This means, for example, you can use template functions like “get_header();” or “get_sidebar();” if your skinning your DW.
First up: Installing Wordpress and/or DokuWiki
For installing WP or DW, refer to the included installation documentation.
Install WP first and make sure everything is up and running before installing DW. Make sure that DW is installed in a directory at the same level as WP or as a subdirectory of WP. This is to make sure that the cookie domains are the same.
In my test environment I had wordpress installed @ ~/public_html/test/wp and DW installed @ ~/public_html/test/dw.
Now, configuring DokuWiki…
First, copy “wordpress.class.php” to
I have it configured by default to assume that dokuwiki is installed at the same level as WP and that WP is installed in a directory called “wp”.
acl.auth.php
You probably created a “conf/acl.auth.php” when you installed DW initially. If you didn’t, make a copy of conf/acl.auth.php.dist and name it “acl.auth.php”.
local.php
You probably created a “conf/local.php” when you installed DW initially. If you didn’t, make a copy of conf/local.php.dist and name it “local.php”. Open it in your favorite text editor and add (or modify) these settings:
Finally, modifying your SQL Database
First, backup your database. You can do this quite easily via WP’s Database plugin.
You need to create two new tables to support DW. In the code below I’ve called these tables “wp_dw_groups” and “wp_dw_usergroups”. If you did not use “wp_” as your database prefix for Wordpress, you will need to modify these commands before you use them and replace “wp_” with the prefix you used. “wordpress.class.php” uses the database prefix to reference these tables.
Connect to your database and run these two commands:
These will create the two tables you need. However, you need to setup some groups too. So these two commands will create a user and an admin group.
Now you need to give yourself admin rights. Normally the first user created in WP is the admin account. This normally has the ID of 1. So now we will add admin user to admin and user groups.
Finished
Now you should be able to login and logout using your WP’s users on DW!
Guest
April 27th, 2007 at 9:59 am
ooops, here is the code, i use
// kill magic quotes… again!
//if (get_magic_quotes_gpc()) {
if (!empty($_GET)) remove_magic_quotes($_GET);
if (!empty($_POST)) remove_magic_quotes($_POST);
if (!empty($_COOKIE)) remove_magic_quotes($_COOKIE);
if (!empty($_REQUEST)) remove_magic_quotes($_REQUEST);
if (!empty($_SESSION)) remove_magic_quotes($_SESSION); #FIXME needed ?
@ini_set(’magic_quotes_gpc’, 0);
// }
@set_magic_quotes_runtime(0);
Thx for great this extension
Guest
April 27th, 2007 at 9:57 am
In fact, the link is good, but not the code (in my case).
My php.ini says magic_quotes-* are off (as phpinfo says), so, the ‘get_magic_quotes_gpc()’ test returns ‘false’ and the remove_magic_quotes(*) does not apply.
I comment the test, and, all is ok on DK with your extension.
—8
Administrator
April 27th, 2007 at 9:42 am
Are you sure? It doesn’t look like it to me. It points to the 1.2 version and if I download it, it grabs the 1.2 zip. Does the zip contain the wrong files?
Guest
April 27th, 2007 at 9:38 am
the link still points on the bad version
* Version 1.1 (3rd October 2006)
March 22nd, 2007 at 4:38 pm
[...] my blog have all been about the Game Crafters Guild website and mostly technical in nature. Here, here and [...]
Administrator
November 26th, 2006 at 10:44 pm
Thanks Camel for the updates! I’ll try and update the file over the next week.
Guest
November 26th, 2006 at 7:32 am
I got it, add this line to wp-config.php:
define(’COOKIEPATH’, ‘/’);
BTW, these:
// grab the rest from the db
$info = $this->getUserData($user);
$USERINFO['grps'] = $info['grps'];
$USERINFO['mail'] = $info['mail'];
should change to:
// grab the rest from the db
$info = $this->getUserData($user);
$USERINFO['name'] = $info['name'];
$USERINFO['grps'] = $info['grps'];
$USERINFO['mail'] = $info['mail'];
for show the ‘nice name’ in wiki page.
sorry for the 3rd post..
Guest
November 26th, 2006 at 6:02 am
BTW, I’m not a programer, so I don’t know so much about PHP and Cookie. I can’t get wordpress.class.php work unless I put DW as a subdir of WP. How can I get them work in the same level directory?
Thanks a lot.
Guest
November 26th, 2006 at 4:44 am
hello,
I found out that version 1.2 won’t work with DokuWiki 2006-11-06.
in the new version of auth.php:
// do the login either by cookie or provided credentials
if($conf['useacl']){
if (!isset($_REQUEST['u'])) $_REQUEST['u'] = ”;
if (!isset($_REQUEST['p'])) $_REQUEST['p'] = ”;
if (!isset($_REQUEST['r'])) $_REQUEST['r'] = ”;
// if no credentials were given try to use HTTP auth (for SSO)
if(empty($_REQUEST['u']) && empty($_COOKIE[DOKU_COOKIE]) && !empty($_SERVER['PHP_AUTH_USER'])){
$_REQUEST['u'] = $_SERVER['PHP_AUTH_USER'];
$_REQUEST['p'] = $_SERVER['PHP_AUTH_PW'];
}
// external trust mechanism in place?
if(!is_null($auth) && $auth->canDo(’external’)){
$auth->trustExternal($_REQUEST['u'],$_REQUEST['p'],$_REQUEST['r']);
}else{
auth_login($_REQUEST['u'],$_REQUEST['p'],$_REQUEST['r']);
}
and the current version of wordpress.class.php:
// someone used the login form!
if(isset($user)){
if($this->checkPass($user,$pass)){
/* Copied this from wp-login.php, not sure exactly what it’s doing!
But we know everything is good so we should be logged in! */
do_action(’wp_authenticate’, array(&$user, &$pass));
$user_obj = new WP_User(0, $user);
wp_login($user, $pass, true);
auth.php will always call $auth->trustExternal with ’set’ $user and $pass.
so I’ve change:
// someone used the login form!
if(isset($user)){
to:
// someone used the login form!
//if(isset($user)){
if(!empty($user)){
maybe you should do something like that in the new version of wordpress.class.php
Administrator
October 16th, 2006 at 11:44 am
Sorry about this, but the link on the page for 1.2 was actually point to 1.1. Updated now. The proper link for 1.2 is http://thedeadone.net/wp-content/sw/Wordpress/Wordpress&DokuWiki1.2.zip