• Resolved pittishgunner

    (@pittishgunner)


    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.

Viewing 1 replies (of 1 total)
  • Thread Starter pittishgunner

    (@pittishgunner)

    I think I answered my question during writing it.
    I used wp_cache_flush(); just before $user = new WP_User($user_id); and all is ok, I should have flushed only the necessary key instead of the whole object cache but I didn’t really have the time to find out the key name.

Viewing 1 replies (of 1 total)
  • The topic ‘new WP_User cached ?’ is closed to new replies.