Where to hook user login? - Printable Version +- MyBB Community Forums (https://community.mybb.com) +-- Forum: Extensions (https://community.mybb.com/forum-201.html) +--- Forum: Plugins (https://community.mybb.com/forum-73.html) +---- Forum: Plugin Development (https://community.mybb.com/forum-68.html) +---- Thread: Where to hook user login? (/thread-170142.html) |
Where to hook user login? - patrick - 2015-04-28 With what hook can I get any log in? With any I mean including the log in of users that are already logged in and return to the site. RE: Where to hook user login? - Destroy666 - 2015-04-29 I'm not completely sure what you mean, but try datahandler_login_complete_end: https://github.com/mybb/mybb/blob/feature/inc/datahandlers/login.php#L310 (or _start) RE: Where to hook user login? - patrick - 2015-04-29 Thanks for helping Destroy666 I'm trying to hook the user log in to detect multiple accounts accessing from the same IP. I've just tried to hook with a a simple echo statement to see what hook was being called: datahandler_login_complete_end (and _start) and it's not being called datahandler_login_validate_start/end aren't eihter member_do_login_start and member_do_login_end are, but user->uid isn't set. RE: Where to hook user login? - Destroy666 - 2015-04-29 Are you using 1.6 or 1.8? This info should be included if it's not the latest 1.8.4 version. Otherwise login datahandler hooks should work fine and you can access UID with $this->login_data['uid']: https://github.com/mybb/mybb/blob/feature/inc/datahandlers/login.php#L238 (where $this is the passed hook parameter) In 1.6 you can use member_do_login_end as you said: https://github.com/mybb/mybb/blob/master/member.php#L1277 UID is in $user['uid']: https://github.com/mybb/mybb/blob/master/member.php#L1260 (don't forget to globalize $user in your function). RE: Where to hook user login? - patrick - 2015-04-29 I'll check it when I have some spare time. Thank you. RE: Where to hook user login? - Bluestone - 2015-12-01 (2015-04-29, 03:56 PM)Destroy666 Wrote: Are you using 1.6 or 1.8? This info should be included if it's not the latest 1.8.4 version. Otherwise login datahandler hooks should work fine and you can access UID with $this->login_data['uid']: https://github.com/mybb/mybb/blob/feature/inc/datahandlers/login.php#L238 (where $this is the passed hook parameter) That didn't work for me. Just getting a blank page. Any idea what am I missing?
RE: Where to hook user login? - StefanT - 2015-12-01 You can't use $this outside of a class. RE: Where to hook user login? - Bluestone - 2015-12-01 (2015-12-01, 09:41 AM)StefanT Wrote: You can't use $this outside of a class. I thought that didn't matter because I hooked my function to it. Got it working, cheers. |