Firefox PHP

Integrating with a non-website user system

Posted by J. David Smith 
Integrating with a non-website user system
August 20, 2011 05:41PM
There seem to be a lot of similar threads to this in this forum, but none that exactly answers my question. I'm the dev in charge of setting up a new forum system for a game that we're running (non-commercial, in case you're wondering). I chose phorum because I've had really good experiences with it in the past. I was able to get every requirement satisfied except one by installing modules.

So, for some background: We have a very, very large pre-existing user database and want users to be able to log into the new forum without having to register. From what I've read, I need to hook into user_authenticate and do something like this:
Language: PHP
$external_user = get_external_user($user,$pass); //Assume this function pulls user data from our main tables. FALSE is a failed lookup. if($external_user) { $phorum_user = phorum_api_user_get($external_user['guid']); if(empty($phorum_user) { //** CREATE USER **// } //** LOGIN USER **// }

Is this the right way to do it or should I do it another way?



Edited 1 time(s). Last edit at 08/20/2011 05:44PM by J. David Smith.
Re: Integrating with a non-website user system
August 20, 2011 11:59PM
That should indeed work. You could also take care of creating the user directly from your user system, but doing it on the fly at login time can be easier to implement.


Maurice Makaay
Phorum Development Team
my blog linkedin profile secret sauce
Re: Integrating with a non-website user system
August 21, 2011 03:05AM
Definitely. Our user table is over a gigabyte, most of which is inactive accounts which we won't want copied over.

Thanks for the confirmation.
Re: Integrating with a non-website user system
January 05, 2012 06:16PM
I have a working module which hooks user_authenticate and before/after_register to integrate our site. We have a separate method of changing user passwords in-game, but this would cause confusion when users change their password on the forums but the change is not reflected in the game. To solve this, I tried hooking user_save and cc_save_user to update the password in our game DB when the phorum password is changed, but my hooked function is not running.

Or, rather, it is running every time a user is updated EXCEPT for on the 'Change Password' page. What am I missing?



Edited 1 time(s). Last edit at 01/05/2012 06:25PM by J. David Smith.
Re: Integrating with a non-website user system
January 05, 2012 06:54PM
I see nothing special in the code for this page. Its calling the same functions as every other controlcenter page. could it be that you changed that page already? see include/controlcenter/password.php .


Thomas Seifert
Phorum Development Team / Mysnip-Solutions.de
Custom Phorum and general software development
worry-free Phorum Hosting
Re: Integrating with a non-website user system
January 05, 2012 06:59PM
I have not modified any of the phorum core files. I added a mod and modified one of the templates. The hook does not fire regardless of the state of the template, however. (I tried with both the default emerald cc_usersettings.tpl and my modified version and in both cases the hook did not fire).
Re: Integrating with a non-website user system
January 05, 2012 07:54PM
the hook is in the core code, cc_user_save in control.php for example. Sorry, like I told, I see no way how this could not fire in this case. Does your code do any checks which could avoid the main code being executed. did you try some output at the beginning of your code to see if it really doesn't get fired?


Thomas Seifert
Phorum Development Team / Mysnip-Solutions.de
Custom Phorum and general software development
worry-free Phorum Hosting
Re: Integrating with a non-website user system
January 05, 2012 07:58PM
Or is it simply that you don't see the output you are expecting? The controlcenter code does a redirect after changing the password to make sure CSRF token is refreshed which is based on the session id which is changed by changing the password.


Thomas Seifert
Phorum Development Team / Mysnip-Solutions.de
Custom Phorum and general software development
worry-free Phorum Hosting
Re: Integrating with a non-website user system
January 05, 2012 08:06PM
Initially it was because I did not see any output. However, I tried changing what it wrote to my DB to a dummy value and the value was never set. Once I discovered that I could get some output by not returning the data array I figured out what I was doing wrong (typo). Sorry for the trouble and thanks for the help!



Edited 1 time(s). Last edit at 01/05/2012 08:06PM by J. David Smith.
Sorry, only registered users may post in this forum.

Click here to login