Hi guys, I have some custom plugins and theme that allow me to have some advanced user features on my website.
I have a bit of a problem and this is the first time in quite a few years I cannot find a single answer to this on these forums.
Basically I register a user with wp_create_user() then I manually update the user_login field in the wp_users table (to have it's id in the username).
All works well except after doing this I also send the user (and admin) a notification of his account (containing the password so this is the only time I have it in plain text). My issue is that in the notification function I use $user = new WP_User($user_id); to get the new user_login but it seems to get the original user_login not the newly manually updated one.
I could pass the notification function the new user_login but I would also like to know why this happens. I'm guessing WP_User caches this data for later use and id this is the case there has to be a way to reset the WP_User object.
Thank you.