Customizing SMF > Portals, Bridges, and Integrations
New tools to help integrating SMF with something else
Andre N:
--- Quote from: jershell on March 11, 2012, 09:45:22 AM ---Hello, please tell me what the function sends a letter confirming email? when you call smfapi_registermember, the user is created, but the letter was not sent when the 'require' => 'activation'.
PS: Sorry my english, written by "Google Translator".
--- End quote ---
Try adding this code to the bottom of the smfapi_registerMember() function to add confirmation emails being sent. Put it just before the member ID is returned:
--- Code: ---global $sourcedir;
require_once($sourcedir . '/Subs-Post.php'); //needed for sendmail and loadEmailTemplate functions
if ($regOptions['require'] == 'activation' || $regOptions['require'] == 'coppa')
{
$replacements = array(
'REALNAME' => $regOptions['register_vars']['real_name'],
'USERNAME' => $regOptions['username'],
'PASSWORD' => $regOptions['password'],
'FORGOTPASSWORDLINK' => $scripturl . '?action=reminder',
'OPENID' => !empty($regOptions['openid']) ? $regOptions['openid'] : '',
);
if ($regOptions['require'] == 'activation')
$replacements += array(
'ACTIVATIONLINK' => $scripturl . '?action=activate;u=' . $memberID . ';code=' . $validation_code,
'ACTIVATIONLINKWITHOUTCODE' => $scripturl . '?action=activate;u=' . $memberID,
'ACTIVATIONCODE' => $validation_code,
);
else
$replacements += array(
'COPPALINK' => $scripturl . '?action=coppa;u=' . $memberID,
);
$emaildata = loadEmailTemplate('register_' . ($regOptions['auth_method'] == 'openid' ? 'openid_' : '') . ($regOptions['require'] == 'activation' ? 'activate' : 'coppa'), $replacements);
sendmail($regOptions['email'], $emaildata['subject'], $emaildata['body'], null, null, false, 0);
}
--- End code ---
You might need to make some modifications to get it to work but that's the way SMF is doing it. If you are registering a member through another system though, and using the API to register them in SMF, why not let the other system handle the confirmation and the rest of it too?
colby2152:
Where is the API file? :o
Kindred:
ummmmm..... attached to the first post in this thread, silly....
kristen_tg:
Andre, I'm having a few issues with the API. I am attempting to integrate it with a custom webapp, nothing more than when the user logs into the site they also get logged into the forums.
Right now I'm just working on the sign in side of things:
--- Code: ---Notice: Undefined variable: cookieData in /home/public_html/forums_3/smf_2_api.php on line 1909
Notice: A session had already been started - ignoring session_start() in /home/public_html/security_scripts/signin.php on line 56
--- End code ---
The user is properly logged into the SMF forums but NOT the application. The session, however, contains the proper information my system needs to validate it.
What's in smf_2_api.php that might be causing this? I suspect it's smfapi_loadSession() although it shouldn't execute if a session already exists (should it?)
ETA:
I solved the loadSesssion() error. Feel a little silly now. :o Too many 14 hours days in a row....
Still getting the $cookiedata notice. Would that be a cookie path issue?
Andre N:
Hi kristen_tg,
The API doesn't really need a session for anything. You can prevent it from starting one, or start your other webapp session first. loadSession won't start a session if one exists but it will always be called.
For the error, looks like $cookieData wasn't declared by the time the script got to line 1909, which means that your SMF cookie probably isn't set yet because it didn't go through the previous if/elseif block that would've set it.
You could add the @ operator to suppress the error from having the variable unset like this:
--- Code: ---if (0 == $id_member) {
$unserializedData = array();
$success = funserialize(@$cookieData, $unserializedData);
if ($success) {
$id_member = $unserializedData[0];
$password = $unserializedData[1];
} else {
// they're either a guest or your cookie is not visible
}
}
--- End code ---
Or, probably safer, declare $cookieData again just in case...
--- Code: ---if (0 == $id_member) {
$unserializedData = array();
$cookieData = stripslashes($_COOKIE[$cookiename]);
$success = funserialize($cookieData, $unserializedData);
if ($success) {
$id_member = $unserializedData[0];
$password = $unserializedData[1];
} else {
// they're either a guest or your cookie is not visible (need subdomain independent cookies)
}
}
--- End code ---
let me know how that works :)
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version