News:

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

Main Menu

Help with registration

Started by Snakeman, June 13, 2012, 12:48:28 PM

Previous topic - Next topic

Snakeman

I'm making a gamemode for sa-mp online hxxp:game.it [nonactive] works synchronized with my simple machines forum.If you register ingame,you can use your account in smf too.If you register at site,you can use your account in game too.
Because of this,i need a code for registration.
Example:

INSERT INTO smf_members ("Snakeman"...)

Thanks..[/b]

emanuele

Hello Snakeman and welcome to sm.org! :)

You may want to use SMF function registerMember, this is an example taken from ManageRegistrations.php:

$regOptions = array(
'interface' => 'admin',
'username' => $_POST['user'],
'email' => $_POST['email'],
'password' => $_POST['password'],
'password_check' => $_POST['password'],
'check_reserved_name' => true,
'check_password_strength' => false,
'check_email_ban' => false,
'send_welcome_email' => isset($_POST['emailPassword']) || empty($_POST['password']),
'require' => isset($_POST['emailActivate']) ? 'activation' : 'nothing',
'memberGroup' => empty($_POST['group']) || !allowedTo('manage_membergroups') ? 0 : (int) $_POST['group'],
);

require_once($sourcedir . '/Subs-Members.php');
$memberID = registerMember($regOptions);


You have to fill the array $regOptions with the few informations required (interface should be guest and not admin in your case I think), and SMF will take care of create the user.


Take a peek at what I'm doing! ;D




Hai bisogno di supporto in Italiano?

Aiutateci ad aiutarvi: spiegate bene il vostro problema: no, "non funziona" non è una spiegazione!!
1) Cosa fai,
2) cosa ti aspetti,
3) cosa ottieni.

Snakeman

Quote from: emanuele on June 13, 2012, 01:22:36 PM
Hello Snakeman and welcome to hxxp:sm.org [nonactive]! :)

You may want to use SMF function registerMember, this is an example taken from ManageRegistrations.php:

$regOptions = array(
'interface' => 'admin',
'username' => $_POST['user'],
'email' => $_POST['email'],
'password' => $_POST['password'],
'password_check' => $_POST['password'],
'check_reserved_name' => true,
'check_password_strength' => false,
'check_email_ban' => false,
'send_welcome_email' => isset($_POST['emailPassword']) || empty($_POST['password']),
'require' => isset($_POST['emailActivate']) ? 'activation' : 'nothing',
'memberGroup' => empty($_POST['group']) || !allowedTo('manage_membergroups') ? 0 : (int) $_POST['group'],
);

require_once($sourcedir . '/Subs-Members.php');
$memberID = registerMember($regOptions);


You have to fill the array $regOptions with the few informations required (interface should be guest and not admin in your case I think), and SMF will take care of create the user.
My friends tells me that,you must fill all coloumns at smf_members table.I told them that i must only fill required coloumns and smf will take care of the others.They don't believed me :) Thank you very much,that's what i wanted,but i need it as INSERT INTO command.

emanuele

I'd really suggest you to use the function instead of directly insert things, this is way more reliable and it will be compatible with future versions of SMF.
Additionally the members table is not the only one that is populated when a user registers.

If you really want to go with the insert, I think it would be better if you check the registerMember function and see what is mandatory and what is not and how things must be stored (remember the password is encrypted for example).


Take a peek at what I'm doing! ;D




Hai bisogno di supporto in Italiano?

Aiutateci ad aiutarvi: spiegate bene il vostro problema: no, "non funziona" non è una spiegazione!!
1) Cosa fai,
2) cosa ti aspetti,
3) cosa ottieni.

Snakeman

Quote from: emanuele on June 13, 2012, 04:21:35 PM
I'd really suggest you to use the function instead of directly insert things, this is way more reliable and it will be compatible with future versions of SMF.
Additionally the members table is not the only one that is populated when a user registers.

If you really want to go with the insert, I think it would be better if you check the registerMember function and see what is mandatory and what is not and how things must be stored (remember the password is encrypted for example).
OK,i will try to make this with registerMember function.Thank you.

Snakeman

Well,i did with registerMember,my register php is this:

<?php
define
('SMF'1);
$regOptions = array(
'interface' => 'guest',
'username' => $_GET['isim'],
'email' => $_GET['email'],
'password' => $_GET['sifre'],
'password_check' => $_GET['sifre'],
'check_reserved_name' => true,
'check_password_strength' => false,
'check_email_ban' => false,
'send_welcome_email' => isset($_GET['emailPassword']) || empty($_GET['password']),
'require' => isset($_POST['emailActivate']) ? 'activation' 'nothing',
'memberGroup' => empty($_GET['group']) || !allowedTo('manage_membergroups') ? : (int) $_GET['group'],
);

require_once('forum/Sources/Subs-Members.php');
registerMember($regOptions);
?>



But there is an error;

Fatal error: Call to undefined function loadLanguage() in C:\inetpub\vhosts\element-samp.net\httpdocs\forum\Sources\Subs-Members.php on line 464

emanuele

Instead of:
<?php
define
('SMF'1);

use:
<?php
require_once('/paht/to/smf/directory/SSI.php');


Take a peek at what I'm doing! ;D




Hai bisogno di supporto in Italiano?

Aiutateci ad aiutarvi: spiegate bene il vostro problema: no, "non funziona" non è una spiegazione!!
1) Cosa fai,
2) cosa ti aspetti,
3) cosa ottieni.

Snakeman

Done,it registers now. Thank you a lot,emanuele.

Advertisement: