wp_update_user doesn’t update and update_user_meta does

wp_update_user & metadata

wp_update_user updates records in the *_users table. It isn’t meant to update custom metadata in the *_usermeta table.

Hence your “problem” is actually expected behavior.

The $userdata argument passed to wp_update_user can contain the following fields:

ID, user_pass, user_login, user_nicename, user_url, user_email, display_name, nickname, first_name, last_name, description, rich_editing, user_registered, role, show_admin_bar_front

Further it accepts metadata that is recognized as a “contact method”. This it will save to the *_usermeta table.

By default, those are jabber, aim & yim.

These can however be altered / appended to by means of the 'user_contactmethods' filter. As for the question raised in the comments, that is likely how twitter & facebook metadata have been made saveable via wp_update_user.

Any additional metadata should be saved as such with the appropriate functions.

How does it happen in the core?

This just as an aside:

wp_update_user calls _get_additional_user_keys which in turn calls _wp_get_user_contactmethods. The resulting metakeys are iterated over back in wp_update_user and if a value exists added to the *_usermeta table via update_user_meta.

For reference, see Line 1426 and after (as of 3.5.1) of /wp-includes/user.php

Leave a Comment