Vanilla 1 is no longer supported or maintained. If you need a copy, you can get it here.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

Trying to integrate Vanilla with existing user system??

edited June 2007 in Vanilla 1.0 Help
Hi, This looks like a great piece of software, and I am interested in using it in future instead of phpbb and other forums which I currently use on my numerous community sites. Anyway, my current personal project consists of a community site which now needs a forum added. The site already has a user sign up system (my own work - PHP/mysql etc), with user db and session spawning etc... My question is - can anyone help guide me in the right direction to what I need to add to my registration class, so that it can populate the vanilla user table at the same time (I don't want to have the user re-registering on vanilla if they want to post)... If I can get this working, I will then try this discussion - - to integrate the login procedure in one... But if anyone has any better ideas, I will gladly accept them. Thanks very much, Alek.


  • Actually, can I do it by simply seeing the Vanilla user db, and then adding to my own sign up class some code to fill in the user data there too? Is LUM_User the only table I need to populate?
  • I think that you need to populate the LUM_Role as well.
  • To me, it is simpler to disable Vanilla's login procedure and just use ours.
    What I personaly did was:
    • remove the login/register thing from my Vanilla templates
    • replace Vanilla's header section by mine (navigation + login...)
    • remap some Vanilla tables to mine
    • create my own auth class (replaces People.Class.Authenticator.php) that doesn't check user pass but only grabs the id of the user (that he got after OUR login procedure
    I took inspiration from this article.
    Hope this helps...
  • Thanks for the replies so far. grahack, the first two points are ok... but... "remap some Vanilla tables"... Do you mean use the Vanilla user table instead of your own one? what other table apart from LUM_User is needed? LUM_Role? My current user system has quite a simple user table. I guess I will need to convert my code to use the Vanilla table instead.. And also, "create your own auth class"... I think this is slightly beyond my understanding at the moment..... Is there anything a little simpler and less specific than the wordpress article? I know PHP fairly well, but I don't want this to be a big job if possible..
  • Our favorite forum engine allows us to use other database tables than the built-in ones (see this section: Merging databases). I guess your user system gives an id to a visitor if this one has success with the login form, like Vanilla does. A part of the first step (allowing you to use Vanilla login form) would be to swap the database config items:

    // Map to the alek-uk app user table
    $DatabaseTables['User'] = 'alek_users';
    // Map existing alek-uk columns to Vanilla
    $DatabaseColumns['User']['UserID'] = alek_'ID';
    $DatabaseColumns['User']['Name'] = 'alek_user_login';
    $DatabaseColumns['User']['Password'] = 'alek_user_pass';
    $DatabaseColumns['User']['Email'] = 'alek_user_email';
    $DatabaseColumns['User']['DateFirstVisit'] = 'alek_user_registered';
    Then every call to the database tables would falls on yours, so you can use the information created with YOUR auth system.
    In fact, when you say Do you mean use the Vanilla user table instead of your own one?, it's the exact contrary: use your tables instead of Vanilla ones. But you'll have to complete your tables for them to have all the needed columns (you'll have to know a bit of SQL).

    But we can go even further: every time that Vanilla wants to know who browses, it calls the authenticator class, that we can swap for another one too !!!
    (flexibility, flexibility, thanks to Mark!!!)

    It's not a big big job: basically tell the new auth class what query to use to return the user_id.

    Do you already have information in your databases? or do you just need to build a fresh system?
  • Thanks for your time Grahack... I'm beginning to understand the logistics I think. The wordpress article was a bit scary at first but reading through it, everything seems a bit clearer.. Of course I knew I could convert my user table and add the needed columns, I guess I'm just worried about the auth class business.... Once I have the database merged, will I have to write something like the 'wordpress authenticator class'? It seems quite complex when all I want is to spawn a session.. Did you have to write something similar for your system?
  • In library/People/People.Class.Authenticator.php, you'll find three important functions: Authenticate, DeAuthenticate and GetIdentity

    I personnaly don't use the two first since I disabled the buttons in the templates, but I rewrote the third to tell Vanilla if someone is already logged in (return $UserID>0) or not (return $UserID=0), AND to do some session stuff (session_set_cookie_params, session_start, AssignSessionUserID) or tracking stuff (UpdateLastVisit, LogIp).

    Maybe GetIdentity is good as is if your personal 'log_user_in' function does exactly the same job, but I guess not.

    You could choose to do only this, or to let users try to log with the Vanilla form too. Then you'll have to rewrite Authenticate and DeAuthenticate.

    If you choose to rewrite, don't forget to set $Configuration['AUTHENTICATION_MODULE'] = 'People/People.Class.ALEK_Authenticator.php';

    My last words: if you've done it in your own auth system, it won't be very hard to do it inside Vanilla.
  • Hey, I am trying to get the UserID from a page outside the Vanilla forum using getidentity() but I just get always 0 as an answered, can someone help with this?
This discussion has been closed.