Refreshing get_currentuserinfo
-
Hi,
I have created a custom user Account Settings page that lets WP users update their account information including additional custom fields that get attached to that user’s metadata. One of the fields that can be updated is the user’s email address.
I display the currently logged in user’s email address in my header.php file. I use
get_currentuserinfo
to display the currently logged-in user’s email address in the header that is displayed on all pages throughout the site.When the user updates the email address of their account by submitting my Account Settings form, the form confirms that the email address is unique, and displays a “Your profile has been updated” message after the successful update (the PHP form evaluates itself, displays errors, and accomplishes the
wp_update_user
andupdate_user_meta
functions). The problem I’m encountering is that when the form page evaluates itself and successfully updates the user record, the email address in the header.php file isn’t updated to reflect the changed email address. I’ve tried resetting the WP auth cookie at the time that the profile is updated, but that doesn’t cause header.php to pick up the new email address. So far the only way I can get the web page (and thus header.php) to display the new email address is to reload the page in the browser.I suppose I could have the account settings page redirect to itself after a successful user profile update, but I’m not sure if that’s necessary or the best way to accomplish what I’m trying to do.
Any suggestions for the best way to accomplish what I intend, e.g. that a successful update of the user’s email address is reflected in my header.php file after the update?
- The topic ‘Refreshing get_currentuserinfo’ is closed to new replies.