News:

Bored?  Looking to kill some time?  Want to chat with other SMF users?  Join us in IRC chat or Discord

Main Menu

Single registration for site and SMF

Started by Staggan, May 09, 2014, 11:38:31 AM

Previous topic - Next topic

Staggan

Hello

I am moving from PHPBB to SMF....  but I currently have a single registration process which registers a user into both our site and PHPBB at the same time...

Is this possible with SMF?

Thanks

Arantor

There are various ways of doing it. The simplest is to just include SSI.php (bundled with SMF) into the site code that you're using and the session will generally be automatically loaded for you.

It would be useful to know exactly what you're currently working with, to know how much you're expecting to happen and then we can give you some idea of the ease of doing it. Pretty much anything is possible, it's only really a question of how much effort and whether the effort is practical.
Holder of controversial views, all of which my own.


Staggan

We have our own site registration and login...

When a user registers on our site we want to register them into the forum at the same time... and when they login to the site we want them to be logged into the forums.. and then just remove the forum login / registration process.. or at least disable it.. which is how our current site works with PHPBB

Thanks

Arantor

Ah, that's probably the most complicated way to do it.

Yes, it's possible, it's just made so much more difficult than just reusing SMF's all in one deal...
Holder of controversial views, all of which my own.


Staggan

Unfortunately it is not a choice, we have to do it this way, and SMF seemed a better solution than PHPBB as it is so slow.....

Can you direct me to where I need to be looking?

Thanks

Dragooon

You can disable registrations via ACP options (have a look at Admin > Members > Registration) or nuke Register.php entirely to make sure they don't register. To programatically register members, you'll need registerMember function in Subs-Members.php. Here's a sample on how to use it:

registerMember(array(
    'interface' => 'guest',
    'auth_method' => 'passwd',
    'username' => 'Dragooon',
    'password' => 'iamawesome' // This is the raw text password, not hashed
    'password_check' => 'iamawesome',
    'email' => '[email protected]',
));


In order to login you'll need LogInOut.php's DoLogin function, I think you need to load the member's row from smf_members table into a global $user_settings to perform the SMF cookie generation. This is all from memory, plus this is not counting for additional SMF features such as custom profile fields etc, make sure to do a lot of testing.

Staggan

Hello

I tried including the file you suggested but it causes some problems with my current code.... no idea why... and no errors being given to suggest why.




Staggan

I have now managed to sort most of this... but I get this error when calling registerMember

PHP Fatal error:  Cannot pass parameter 1 by reference

This is the code for the call:



registerMember(array(
'interface' => 'guest',
'auth_method' => 'passwd',
'username' => $username,
'password' => $password, // This is the raw text password, not hashed
'password_check' => $password2,
'email' => $email
));



Any ideas?

Thanks

Dragooon

Ah set the options as a separate array variable and pass the variable instead

Staggan

I tried this:



$params = array(
'interface' => 'guest',
'auth_method' => 'passwd',
'username' => $username,
'password' => $password, // This is the raw text password, not hashed
'password_check' => $password2,
'email' => $email
);
registerMember($params);



But I need to check the return from the function as it seems to break my code, although I am not getting an error logged...

Thanks

Staggan

Thanks for all the help...

Using the SMF API I got everything working that I needed


Advertisement: