Jump to content

Custom username from CreateAccount not reaching AfterModuleCreate


niels

Recommended Posts

I have a provisioning module where, in the CreateAccount function, I override the username:

Quote

 

$username = nicerUsername(); 

mysql_query("UPDATE tblhosting SET username="{$username}' WHERE id='{$params['serviceid']}");          

This works completely fine by itself. 

I'm now trying to use the AfterModuleCreate hook to run some additional code without having to change the provisioning module.

The hook is called and runs its code as I expect. However, the username parameter passed to AfterModuleCreate is not the one assigned by CreateAccount. All the other parameters come through fine. (But those parameters are not changed by CreateAccount.)

I'm guessing that whatever function is calling AfterModuleCreate is not re-querying the database after calling CreateAccount, hence not picking up on any changes that CreateAccount made to the database and passing AfterModuleCreate old parameters as a result.

Is my assumption correct? Or am I overlooking something?

The quicky-and-dirty fix is to query the database in my AfterModuleCreate hook and fetch the updated username. But I would like to avoid such trickery if possible.

Link to comment
Share on other sites

1 hour ago, niels said:

I'm guessing that whatever function is calling AfterModuleCreate is not re-querying the database after calling CreateAccount, hence not picking up on any changes that CreateAccount made to the database and passing AfterModuleCreate old parameters as a result.

Exactly. As far as I know all the involved hook points (pre/after/create) keep using the initial username therefore you'll need to re-query the database to get the updated username.

Edited by Kian
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated