[RFC] user_add hook

These requests for events in core phpBB have been merged into 3.1/Ascraeus and will be available with the next release.
User avatar
nickvergessen
Former Team Member
Posts: 733
Joined: Sun Oct 07, 2007 11:54 am
Location: Stuttgart, Germany
Contact:

[RFC] user_add hook

Post by nickvergessen »

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.
Member of the Development-TeamNo Support via PM

igorw
Registered User
Posts: 500
Joined: Thu Jan 04, 2007 11:47 pm

Re: [RFC] user_add hook

Post by igorw »

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
Kellanved
Former Team Member
Posts: 407
Joined: Sun Jul 30, 2006 4:59 pm
Location: Berlin

Re: [RFC] user_add hook

Post by Kellanved »

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.

igorw
Registered User
Posts: 500
Joined: Thu Jan 04, 2007 11:47 pm

Re: [RFC] user_add hook

Post by igorw »

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.

Sam
Registered User
Posts: 31
Joined: Fri Jan 23, 2009 10:24 pm

Re: [RFC] user_add hook

Post by Sam »

I prefer individual hooks, it's much simpler on the MOD author's end.

Jhong
Registered User
Posts: 50
Joined: Tue Dec 26, 2006 3:28 pm

Re: [RFC] user_add hook

Post by Jhong »

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.

gn#36
Registered User
Posts: 8
Joined: Mon Aug 30, 2010 9:09 pm

Re: [RFC] user_add hook

Post by gn#36 »

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).

roelandaernoudts
Registered User
Posts: 7
Joined: Sun Feb 09, 2014 6:25 pm

Re: [RFC] user_add hook

Post by roelandaernoudts »

I am not sure were to post this, but I believe this may be the most logical place. I have been working on further development of rokbridge, a joomla component which bridges joomla and phpbb3, the problem I have run into is that there is now hook for updating users. For example when a user updates a password or changes username. From joomla its events it is pretty easy to make updates to the phpbb3 user using the joomla events. I am now writing a hook to fire an event in joomla to be able to change user info within joomla when user information is altered in phpbb3. However it requires changes to the phpbb3 core, which I prefer not to make.
I would really like to see a hook for an update user information event. I think it will be beneficial to all other platforms that try to bridge or integrate with phpbb3.
I hope I did not put this request in the wrong place, and if I did, please move it to the right place.
Thanks in advance for any comments.

User avatar
DavidIQ
Customisations Team Leader
Customisations Team Leader
Posts: 1904
Joined: Thu Mar 02, 2006 4:29 pm
Location: Earth
Contact:

Re: [RFC] user_add hook

Post by DavidIQ »

You need to create a request for adding a new event in the ucp_profile class. Your request needs to be in the event request format which is why your post can't be moved.
Image

User avatar
brunoais
Registered User
Posts: 964
Joined: Fri Dec 18, 2009 3:55 pm

Re: [RFC] user_add hook

Post by brunoais »

I agree with this hook.

Post Reply