phpBB

Development Discussion Board

phpBB's testing ground of bleeding edge code
Advanced search

[RFC] user_add hook

Request hook events and what data needs to be sent for the new hook system.

[RFC] user_add hook

Postby nickvergessen » Sun Aug 22, 2010 8:08 pm

Name: hook_user_add
Rationale: It might be useful for some MODs to be able to do things when a new user is added.
Placement: includes/functions_user.php inside user_add:
we actually need two inside this function, one before
Code: Select all
   $sql = 'INSERT INTO ' . USERS_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary);
   $db->sql_query($sql);
so we can modify the data, before the user is added to the database, and one after we know the user_id, although one after the user_id would be fine aswell, because we can just make an UPDATE-sql then.
Input arguments: $sql_ary, $cp_data
Output format: $sql_ary, $cp_data per reference before the INSERT, afterwards it should be $cp_data per reference.
cheers nickvergessen :geek:
Member of phpBB Development-Team
No Support via PM — My MODs for phpBB 3.0.x
User avatar
nickvergessen
Development Team
Development Team
 
Posts: 357
Joined: Sun Oct 07, 2007 11:54 am
Location: Esslingen, Germany

Re: [RFC] user_add hook

Postby igorw » Mon Aug 23, 2010 10:02 am

We could call the first one user_add and the second one user_add_after (seems like a more sustainable naming convention than user_added).
User avatar
igorw
Registered User
 
Posts: 500
Joined: Thu Jan 04, 2007 11:47 pm

Re: [RFC] user_add hook

Postby Kellanved » Mon Aug 23, 2010 3:26 pm

we could also - shocking - use the same hook twice. With an argument from where in the function it was called.
No support via PM.
Trust me, I'm a doctor.
User avatar
Kellanved
Registered User
 
Posts: 407
Joined: Sun Jul 30, 2006 4:59 pm
Location: Berlin

Re: [RFC] user_add hook

Postby igorw » Mon Aug 23, 2010 4:42 pm

True, but I'd prefer to see individual hooks in such cases. It keeps the hook API consistent and prevents modders from having to do really awkward if/switch statements in the listeners. Well, that's just a minor detail anyway.
User avatar
igorw
Registered User
 
Posts: 500
Joined: Thu Jan 04, 2007 11:47 pm

Re: [RFC] user_add hook

Postby Sam » Tue Aug 24, 2010 2:52 am

I prefer individual hooks, it's much simpler on the MOD author's end.
User avatar
Sam
Website Team
Website Team
 
Posts: 31
Joined: Fri Jan 23, 2009 10:24 pm

Re: [RFC] user_add hook

Postby Jhong » Wed Aug 25, 2010 4:08 am

A small point, but you might want to consider "user_add" and "user_add_before" instead. I think "before" makes it clear that no changes have been written to the database yet.
Jhong
Registered User
 
Posts: 50
Joined: Tue Dec 26, 2006 3:28 pm

Re: [RFC] user_add hook

Postby gn#36 » Fri Sep 24, 2010 6:42 am

It should be possible to deny adding the user through the "before" hook. A mod might set conditions that must be met, before a user can be added, for example it might check some data entered in custom profile fields (beyond just checking for the correct format, i.e. it might compare a field for membership ID with a table of all members to permit only members that are already in the database to be registered).
gn#36
Registered User
 
Posts: 8
Joined: Mon Aug 30, 2010 9:09 pm


Return to [3.x] Event Requests

Who is online

Users browsing this forum: No registered users and 3 guests