Processing and storing custom user data
As user profiles are created or updated, WordPress offers an easy way to register a callback to save custom user data in the site's database.
Getting ready
You should have already followed the Adding custom fields to the user editor recipe to have a starting point for this recipe. The resulting plugin should still be active on your development site. Alternatively, you can get the resulting code directory (ch8/ch2-private-item-text/*
) from the book's GitHub page and rename ch2-private-item-text-v3.php
to ch2-private-item-text.php
. All other .php
files can be deleted to avoid confusion when activating the plugin.
How to do it...
Follow these steps to register an action hook to save custom user data:
- Navigate to the
ch2-private-item-text
folder of the WordPressplugins
directory of your development installation. - Open the
ch2-private-item-text.php
file in a text editor. - Add the following lines of code at the...