Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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?

share|improve this question
add comment

1 Answer

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

Codex page for get_currentuserinfo()

share|improve this answer
    
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
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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