call registerMember(&)

Started by otario, May 22, 2006, 05:33:13 PM

Previous topic - Next topic

otario

Hi,
is possible register a new member by calling directly "registerMember" (into "Subs-Members.php") from another page of my website??
If yes, what is the "structure/option" i should pass to this function as the first, and only, parameter?!? ::)

otario




Rudolf

In Register.php:

// Set the options needed for registration.
$regOptions = array(
'interface' => 'guest',
'username' => $_POST['user'],
'email' => $_POST['email'],
'password' => $_POST['passwrd1'],
'password_check' => $_POST['passwrd2'],
'check_reserved_name' => true,
'check_password_strength' => true,
'check_email_ban' => true,
'send_welcome_email' => !empty($modSettings['send_welcomeEmail']),
'require' => !empty($modSettings['coppaAge']) && !isset($_POST['skip_coppa']) ? 'coppa' : (empty($modSettings['registration_method']) ? 'nothing' : ($modSettings['registration_method'] == 1 ? 'activation' : 'approval')),
'extra_register_vars' => array(),
'theme_vars' => array(),
);

// Include the additional options that might have been filled in.
foreach ($possible_strings as $var)
if (isset($_POST[$var]))
$regOptions['extra_register_vars'][$var] = '\'' . $_POST[$var] . '\'';
foreach ($possible_ints as $var)
if (isset($_POST[$var]))
$regOptions['extra_register_vars'][$var] = (int) $_POST[$var];
foreach ($possible_floats as $var)
if (isset($_POST[$var]))
$regOptions['extra_register_vars'][$var] = (float) $_POST[$var];
foreach ($possible_bools as $var)
if (isset($_POST[$var]))
$regOptions['extra_register_vars'][$var] = empty($_POST[$var]) ? 0 : 1;

// Registration options are always default options...
if (isset($_POST['default_options']))
$_POST['options'] = isset($_POST['options']) ? $_POST['options'] + $_POST['default_options'] : $_POST['default_options'];
$regOptions['theme_vars'] = isset($_POST['options']) && is_array($_POST['options']) ? $_POST['options'] : array();

$memberID = registerMember($regOptions);

From there you can see the array you have to pass. It's the 'regOptions' array.
Look at the 'registerMember' (in Subs-Members.php) function to understand better what you need.
I will update all my mods in the next few weeks. Thanks for your patience.

SVG-Collapse (you need an SVG compliant browser)

otario

Oh, is so nice.... :D :D
But the 'require' => !emp... field, what should it contains? ???

H

-H
Former Support Team Lead
                              I recommend:
Namecheap (domains)
Fastmail (e-mail)
Linode (VPS)
                             

Orstio

#7

Rudolf

Quote from: otario on May 28, 2006, 10:00:41 AM
Oh, is so nice.... :D :D
But the 'require' => !emp... field, what should it contains? ???

!empty($modSettings['coppaAge']) && !isset($_POST['skip_coppa']) ? 'coppa' : (empty($modSettings['registration_method']) ? 'nothing' : ($modSettings['registration_method'] == 1 ? 'activation' : 'approval'))

let me translate it for you:
<?php
if (!empty($modSettings['coppaAge']) && !isset($_POST['skip_coppa']))
$regOptions['require'] = 'coppa';
elseif (empty(
$modSettings['registration_method']))
$regOptions['require'] = 'nothing';
elseif (
$modSettings['registration_method'] == 1)
$regOptions['require'] = 'activation';
else
$regOptions['require'] = 'approval';
?>


In human words here are the posssible values and their meanings

  • coppa - The user will be required to be over an X age
  • nothing - The user will be activated instantly
  • activation - The user will have to activate his/her account by receiving an email and clicking a link in it.
  • approval - The user will have to be approved by an administrator before he/she can start using the forum

and by the way, I don't see any api function for registration in the smf_api.php file.  ::)
I will update all my mods in the next few weeks. Thanks for your patience.

SVG-Collapse (you need an SVG compliant browser)

otario

thank you rudiksz...
...yeah, i don't have find the smfapi too!  :-\

Advertisement: