share user login between Mediawiki and wordpress (19 posts)

  1. Heliotropen
    Posted 8 years ago #

    ****short resume of this tred have to be;***
    - how to login to MediaWiki with the usernames and passwords from a WordPress blog
    *** lets begin: ***

    A while back spencerp wrote this great guide, on how to make user integration between wordpress, bbpress, and media wiki:


    It a great thing, and i guess many people wants to do soo.

    There is one HUGE problem though (understatement);

    1.First of this plugin wich spencerp uses in his guide, is no longer avaible for download?
    (if it where, i don't know if it works with newest versions of wordpress and mediawiki.)

    2. this IS still avaible:

    And it seems to be great EXCEPT, it's USELESS today, because it dosn't work with the new version of mediawiki and wordpress, as they write on the site:

    "This extension is tested with Mediawiki 1.6.9 (the latest release for PHP4) and wordpress 2.1. It will not work (yet) for Mediawiki > 1.6.9 (because of PHP5) but the next version will be PHP5 ready."

    Well "my" logic was, that php5 is backward compatible, there for it sounded like nonsense; so i just desided to try it out, and guess what, the instructions wast right, - the plugin just don't work with the newest mediawiki; i got the following error, when trying to login with a user from wordpress: "Wiki has a problem

    Sorry! This site is experiencing technical difficulties.

    Try waiting a few minutes and reloading.

    (Can't contact the database server: Unknown error)"

    ******now my question******

    Is there any plugin or way out there, to make the step nr. 4 in the guide possible? (make it possible to login to MediaWiki with the usernames and passwords from a WordPress blog, thats shares the same database.)

    I hope somone smarter than me, has some views and solutions on this topic, as all treads about this subject seems outdated, and the topic seems more important than ever.

    In advance thnx.

    /Helio AKA. Dennis O. Madsen

  2. zimpet
    Posted 8 years ago #

    Hi Heliotropen,

    it is the same for me: a wall of silence (or outdated information - it is more or less the same...) when it comes to the question to integrate Mediawiki and WordPress (and vice versa). And I would like to use both (or three: looking at bbpress). That would be the best of all three worlds: WP, BBpress and Mediawiki. Is there anyone around taking the challenge to get them all down to the same user authentification mechanism? That would be great!


  3. dazburn
    Posted 8 years ago #

    i want to use MediaWiki with WordPress too! Anyone found a DECENT solution yet? I've heard of SingleAuth but it's not ready yet!!

  4. nicollb
    Posted 8 years ago #

    Just another "me too" -- If anyone finds a reasonable way to do this I'd love to know about it.

    I thought of going the OpenID route with the site(s) - but that may be beyond the pale for this particular set of users.

  5. culpus
    Posted 8 years ago #

    ME TOO!!!

    Sorry guys, I'm just another on of those.

  6. Lenary
    Posted 8 years ago #

    how about just put them in the same db, but with different prefixes, and specify a different name for the users table.
    i have a sudden feeling it won't be this simple, because nothing ever is anymore...
    as long as they both access the able with the equivalent of ARRAY_A then you could just add the extra wordpress columns to the mediawiki database, or visa versa...

  7. Slamlander
    Posted 8 years ago #

    Hery is currently busy with Joomla stuff. Besides, I don't think he has access to a PHP5 server. I'll see what I can do to fix it.

    -- The Slamlander

  8. Rune Clausen
    Posted 8 years ago #

    I'll join the chorus... and especially applaude the latest post to this thread! That sounds truly interesting Slamlander - I'll be sure to check back for any news on a possible fix!

  9. pnaw10
    Posted 8 years ago #

    Adding another "me too!" here becuase it's been two months since anything's happened on this thread.

    I'm thinking about adding a MediaWiki to one of my websites, but it HAS to be able to use the same logins as the existing WordPress site. I already have nearly 100 WP users (they have to login to post comments). Requiring them to create separate logins for MediaWiki would be a complete dealbreaker.

  10. Jonathan
    Posted 8 years ago #

    I was just able to get hery's to work. Looking over the code, it all looks safe enough to use with PHP5. A vanilla setup of the AuthWordpress.php file results in logins always failing. The problem is in authenticating the password. That's relatively easy to fix by importing some of WordPress's new hashing functionality in class-phpass.php. I literally made 3-line changes to AuthWordpress.php and got it working with WordPress 2.6 and MediaWiki 1.12 (as of this writing the latest version).

    After line 58 add the require line for class-phpass.php so it looks like this:


    You may need to adjust your path to class-phpass.php depending on your file layout. In my setup, MediaWiki is in a sub-directory of the WordPress install (e.g. /wordpress/wiki, so the path to the class would be /wordpress/wp-includes/class-phpass.php)

    Next you need to alter the authenticate() function in AuthWordpress.php to use the new password hasher.

    Around line 175 (176 if you added the line above), find the line that looks like this:
    if( $res && ( $res->user_pass == MD5( $password ))) {

    Add the following code as a new line BEFORE the if statement to create the PasswordHash object:
    $wp_hasher = new PasswordHash(8, TRUE);

    Now replace the if line:
    if( $res && ( $res->user_pass == MD5( $password ))) {

    with the following:
    if( $res && $wp_hasher->CheckPassword($password, $res->user_pass)) {

    Boom, login works. Now if only I could figure out how to share the session. Hope this helps someone else.

  11. Jonathan
    Posted 8 years ago #

    Ok, one follow-up. When logging in to MediaWiki from an account that exists in WordPress, but does not (yet) exist in MediaWiki there is a problem creating/copying the account into MediaWiki with AuthWordpress.php

    Find the setPassword() function (around line 272) and change:
    return false;

    return true;

    I think hery was thought that it would set the password in WordPress, when it is actually setting the password in the MediaWiki authentication database. Admittedly, I can't blame hery, the comments in the code are a bit ambiguous when it just says to "the authentication database".

    So 4 lines of changes. Still not bad, thanks hery!

  12. mort
    Posted 8 years ago #

    script links both dead. jondavis, you should consider releasing what you made. would be helpful.


  13. mort
    Posted 8 years ago #

    these changes don't work for me using wp2.6. the user_password fields in MW are blank and logins fail. will update if i find a solution.

  14. mort
    Posted 8 years ago #

    correction-- script does work. mediawiki was throwing internal server errors and "password is too short" due to the test account's password being the same as the username. the db inserts were then failing half way through with blank password entries.

  15. Jonathan
    Posted 8 years ago #

    Ok, the script I modified is available for download off my blog. I wasn't aware that hery took his original down.

    Here's a link to the blog posting with a download available of the modified AuthWordpress.php and full installation instructions:

    WordPress, bbPress & MediaWiki

    I'd appreciate postings of others who get it to work. Feel free to let me know if you run into problems so I can improve the instructions.

  16. pnaw10
    Posted 8 years ago #

    Thanks for posting that. Have you tried this with WordPress 2.5.1 by any chance? I've been holding back on the 2.6 upgrade because of the widget problem and other things I'm not totally convinced about yet.

    I wouldn't mind giving it a shot if the results are currently unknown. But if you or anyone else has already attempted and failed, I won't waste my time... I'll just bite the bullet and upgrade to 2.6.

  17. Jonathan
    Posted 8 years ago #

    @pnaw10 it should work since the password hashing class was introduced into WordPress 2.5. It should work with any version of WordPress 2.5+

  18. JimMcKeeth
    Posted 7 years ago #

    Thanks @jondavis. It worked great. Now I would just like to get the session to be shared so logging into one also logs into the other.

  19. pnaw10
    Posted 7 years ago #

    @jondavis - I finally got around to using your solution this weekend, and yes it worked with WP2.5. I had only two little roadbumps, which were easily overcome.

    First, the WordPress installation I'm "joining" with MediaWiki isn't using the default "wp_" as the prefix for its SQL database tables. I had to change accordingly, line 64 of your AuthWordpress.php and the 4rd line (including the comment) you have us pasting into MediaWiki's LocalSettings.php file. I'm not sure if I had to change it in both places, but it made sense to do so.

    The other little problem I had came in the very next four lines of the snippet pasted into LocalSettings.php:

    $wgAuth->setAuthWordpressDBServer (DBSERVER); // wordpress host (eg. localhost)
    $wgAuth->setAuthWordpressDBName(DBNAME); // wordpress database
    $wgAuth->setAuthWordpressUser(DBUSER); // wordpress db username
    $wgAuth->setAuthWordpressPassword(DBPASSWORD); // wordpress db password

    When you fill in those variables -- DBSERVER, DBNAME, DBUSER and DBPASSWORD -- they need to have single quotes around them. I guess this is a no-brainer for any veteran programmer... but I'm still learning PHP and I take directions very literally. It took me a few unsuccessful login attempts before I realized this, and added in the quotes. Just like magic, everything worked perfectly.

    One other item worth noting: once you make these changes, all access to MediaWiki will be exclusively through WordPress usernames and passwords.

    To help avoid any potential naming problems, I installed MediaWiki with a new, unique username that I was not using on WordPress. Obviously, that account has MW sysop privileges by default. But once I got WordPress and MW linked, I could no longer login with that sysop account. Since there's no password for it in WordPress, I had effectively "locked the keys in the car" so to speak -- until I created a WP account with the same username. I then logged into MW with it, and gave "myself" (my WordPress admin account) sysop rights in MediaWiki.

    I suppose I could have saved myself this step by making my MediaWiki default username the same as my WordPress username.

    Again, I'll stress none of these issues were major problems -- all resolved in a matter of mere minutes. Just wanted to make a note of them in case anyone else runs into the same situation.

Topic Closed

This topic has been closed to new replies.

About this Topic