If I have the wp user object instantiated what is the proper way to update the value of a particular key if it changes during the course of a script? For example, lets say I have this somewhere in my code near the beginning of the script:

echo $current_user->display_name;//lets say this returns 'sometestname'

Then I do something here to change the value of display name in the wp_users table. Let's say I change the display_name to 'someothertestname' using wpdb->query .

echo $current_user->display_name;//still would result in 'sometestname'

What should I be doing here? Is this where wp_cache comes in? How do I update the value in the current object? Or do I?


Assuming you're talking about the current user (as your code fragment shows), you'd call get_currentuserinfo() again.

Codex page for get_currentuserinfo()

  • Really? Is there's no way to just update that one key? That seems like a waste to have to reload all of that data even though it's just one key that needs updating. – michael May 1 '13 at 15:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.