[wp-hackers] Creating / Inserting into Table named after WP Username

J.D. Grimes jdg at codesymphony.co
Mon Aug 26 19:17:07 UTC 2013

On Aug 26, 2013, at 3:06 PM, Gregory Lancaster <greglancaster71 at gmail.com> wrote:

> When you say on the fly, you mean (for example) when a user registers, have
> the user ID copied over into a sep database?  That is actually what I am
> trying to figure out haha.  Id like to have the user->ID copied into a
> separate database row *(or create a new table with the user-ID as the table
> name)* after registration. If I could figure that out then I imagine the
> rest would fall into place for me.  The WP loop is something I am still
> learning, so I really appreciate the reference information *Nicholas. *
> *J.D* - Is that what you meant? Did I understand your question correctly?
> if current_user->ID if exists fetch array($result) echo $row[1]  etc...

Not exactly what I mean. My question was why are you copying the user_ID over at that time - but that may not really be important.

If you need to add some information do the database when a user registers, then you wan to use the user_register action hook as Nicholas said.


But in your function hooked to that hook, you do *not* want to use the ID of the current user. You need to use the ID of the user that has just registered, which will be passed as the first parameter to your hooked function, as shown in the examples there.

Back to my question, though, I'm not sure why you feel you need to do this at the time the user registers. I assume that it has something to do with the date/time oriented aspect of the data that you want to store? I.e., I guess you have some entries that need to go in at that time so they will be dated properly? But you are going to have to do this differently for registered users...

More information about the wp-hackers mailing list