member_do_register_end Hook
#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


Messages In This Thread
member_do_register_end Hook - by Sazze - 2016-01-29, 10:34 PM
RE: member_do_register_end Hook - by nth - 2016-01-29, 10:36 PM
RE: member_do_register_end Hook - by Sazze - 2016-01-29, 10:37 PM
RE: member_do_register_end Hook - by nth - 2016-01-29, 10:43 PM
RE: member_do_register_end Hook - by Omar G. - 2016-01-30, 06:16 AM
RE: member_do_register_end Hook - by Sazze - 2016-01-30, 11:14 AM
RE: member_do_register_end Hook - by Omar G. - 2016-01-30, 07:22 PM
RE: member_do_register_end Hook - by Sazze - 2016-01-30, 09:58 PM
RE: member_do_register_end Hook - by iNilo - 2016-12-22, 10:13 PM
RE: member_do_register_end Hook - by Sazze - 2016-12-23, 02:25 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)