member_do_register_end Hook
#1
If I were to log something, upon registration, how would I do that?

I know I need this hook:
member_do_register_end


but it won't work properly.

Help is appreciated,
Thanks. Toungue
Reply
#2
Why won't it work properly? Show us what you have.
Reply
#3
(2016-01-29, 10:36 PM)nth Wrote: Why won't it work properly? Show us what you have.

As of now, I've nothing. But I need to insert stuff into a table upon registration.
Reply
#4
What data do you need? You can use the $mybb->user object.

function register_user()
{
	global $mybb;
	die(var_dump($mybb->user));
}
$plugins->add_hook("member_do_register_end", "register_user");
Reply
#5
If it is during user insertion rather than registration, hook at the data-handler. It may cover scenarios where the registration code wouldn't. I.e. creating an user from the ACP.
Reply
#6
(2016-01-30, 06:16 AM)Omar G. Wrote: If it is during user insertion rather than registration, hook at the data-handler. It may cover scenarios where the registration code wouldn't. I.e. creating an user from the ACP.

I already have a hook that logs stuff when you login to your account ( datahandler_login_complete_start ) and it works fine. Just need to do it upon registration. I used this for the login part:

function log()
{
	global $db, $loginhandler, $mybb;
        $uid = intval($loginhandler->login_data['uid']);

        // Insert below..
}
Reply
#7
datahandler_user_insert_end for user insertion and member_do_register_end for registration.
Reply
#8
Issue solved.
Reply
#9
(2016-01-30, 09:58 PM)Sazze Wrote: Issue solved.

Could you please post your final results?
Thanks!
Reply
#10
(2016-12-22, 10:13 PM)iNilo Wrote:
(2016-01-30, 09:58 PM)Sazze Wrote: Issue solved.

Could you please post your final results?
Thanks!

You'll have to edit some stuff, but here's an example.

* NOTE: Not tried yet, but it should work.
<?php

defined('IN_MYBB') OR die('Nope');

$plugins->add_hook('datahandler_login_complete_start', 'log_login');
$plugins->add_hook('member_do_register_end', 'log_registration');

function log_info()
{
	return [
		'name'             => 'Log',
		'description'   => 'Log some data upon registration and login.',
		'website'         => 'http://community.mybb.com/user-83692.html',
		'author'           => 'Sazze',
		'authorsite'     => 'http://community.mybb.com/user-83692.html',
		'version'           =>  '1.0',
		'compatibility' => '18*'
	];
}

/* Log data when you sign in to an account */
function log_login()
{
   global $db, $loginhandler, $mybb;

   $uid = intval($loginhandler->login_data['uid']);
   
   if (!$uid)
   {
     return;
   }
   
   $insertStuff = array('uid' => $uid);
   $db->insert_query('myTable', $insertStuff);
}

/* Log data upon registration */
function log_registration()
{
   global $mybb, $user_info, $user, $session, $db;

   $newUID = intval($user_info['uid']);
   
   /* Insert new UID */
   $insertStuff = array('uid' => $newUID);
   $db->insert_query('myTable', $insertStuff);
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)