Support » Plugins » Hacks » $wpdb->update delayed?

  • Hello,

    I am using $wpdb->update to update wp_users.user_email. It works fine. However, when I call get_currentuserinfo() or get_userdata() right after to re-populate the html input fields, I’m getting the old value. If I refresh the screen, either method will return the correct updated value.

    Is there something special I need to do in order to retrieve the value just updated? I’d rather not rely on the original value I passed to $wpdb->update.


Viewing 1 replies (of 1 total)
  • Moderator bcworkz


    The old values are possibly coming from the WP cache. You can call wp_cache_flush() to force WP to go to the DB for the data. Doing this can be undesirable because it’ll probably cause many otherwise unneeded database queries. As long as you properly trap any possible errors, and replicate any trims and other such manipulation, you’re really better off using the original passed value.

    Alternately, figure out how the email is stored in the cache and only remove that one cache item with wp_cache_delete(), so that all other contents are preserved. See Class Reference/WP Object Cache

Viewing 1 replies (of 1 total)
  • The topic ‘$wpdb->update delayed?’ is closed to new replies.