WordPress.org

Ready to get started?Download WordPress

Forums

$wpdb->update delayed? (2 posts)

  1. vinmiller
    Member
    Posted 1 year ago #

    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.

    Thanks,
    Vin

  2. bcworkz
    Member
    Posted 1 year ago #

    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

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.