Hi folks. I’m making good progress on an extension to help keep two different member info databases (one for EE, the other for our catalog system) synced up, changing the secondary db table when actions happen to the members data within EE. I’m jammed up a bit, however, trying to work with a hook labeled member_register_validate_members found in mod.member_register.php
I want to update a pending member to validated status in my secondary db table when folks self-validate using their emailed link. This link includes a unique authorization code passed in the url as id=xxxxxxxx This permits EE to identify the member and update their status within the member table. However, JUST before the hook, the script cleans up after itself and changes the authorization field back to “”.
How do I grab the username of this just changed record? I assume it would be done with mysql_insert_id() to grab the last record worked on, but I don’t know how to write the query. My non-working code (due to the just emptied authcode) is as follows:
function self_validate_other()
{
global $DB, $IN;
$id = $IN->GBL('id');
$OurUsername = "";
$query = $DB->query("SELECT username FROM exp_members WHERE authcode = '".$DB->escape_str($id)."'");
$OurUsername = $query->row['username'];
$DB->query("UPDATE APUsers SET RegistrationConfirmed = '1' WHERE UserName = '$OurUsername'");
}
Any help would be much appreciated 😊
Mod Edit: Moved for you, to Extensions.
Hi WCW,
I’ve recently used the same hook, and to my despair ran into the same problem. I couldn’t see a suitable way out of it and decided that perhaps a feature request could be made to alter the position and/or data made available to extensions on that hook?
I ended up making a minor alteration to the core code (tut tut), moving the query (~line 939) to below the extension call.
mysql_insert_id() can only return data sent back if the query was an insert (with an auto_increment field), which of course this isn’t :(
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.