by c.bavota

Main Menu

Adding Extra Fields to the WordPress User Profile

By default WordPress offers some great options. Whenever a member joins, they have the ability to add more information about themselves, such as a Web site URL, a short bio and their AIM. You might require a bit more info from your members and creating extra fields in the user profile is pretty straightforward.
With the following code, you can add some extra fields asking your members for their address. Just add the code t your theme’s functions.php file, or create a functions.php file if you don’t already have one.

69 comments for “Adding Extra Fields to the WordPress User Profile”

Jan

January 12, 2010 at 2:52 pm

Hi,
This looks very nice, but I have two additional newbie questions:
1. How, in a private blog, where the members cannot register but are registered by the admin, can they nevertheless update their profile with the additional fields?
2. Once the extra user fields are in the database, how to display (selected) fields in a table form on a page?
Best regards,
Jan

Thanks for writing this. I’ve had a few issues with the Register Plus plugin, but this seems way easier to implement and customize. I can’t, however, find any reference to the ‘edit_user_profile_update’ action in the WordPress codex. Do you know if its documented somewhere else, or explains somewhere in the WP code?

Joe

March 2, 2010 at 9:08 am

I have put the code into my functions.php file and it shows up fine in the profile. This issue is when I edit the profile and hit the update profile button, I get a blank page and (profile.php). If I refresh the page, the profile comes back up.

The only different I see between the default action (with the code not in place) and the new action is an some HTML after the profile.php

great little script, works flawlessly in 2.9.2. Displayed perfect in the user profiles and was easily able to add additional fields to the script. In addition, works perfectly with the_author_meta() to display the info on the site.

Hello just thought i would tell you something.. This is twice now i’ve landed on your blog in the last 3 days searching for totally unrelated things. Spooky or what? If you liketo swap the links with us please let me know.

Faizan

April 2, 2010 at 5:00 pm

Hello this is a great tutorial saved me a lot of time. I am just having one issue when put something in the custom textarea which i added to the profile and click update profile it does not get saved. If someone can help me with this problem i would appreciate it. Thank You.

thanks very much for the prompt reply, that is quite refreshing in itself. i tried your suggestion to no avail. i have to admit i did not spend a lot of time on it but i did a little reading and i think “readonly” is strange in php, from what i can tell it would need its own class defined, of which i found a couple examples but have not had the time to try them out or attempt myself. From what i read however, “readonly” is somewhat of an anomaly in php. If you feel like messing with it that would be cool and i would love to see your resolution but certainly don’t pull your hair out over it since, as i said, my method works perfectly, just quite ugly!

hi
i’ve been trying for long to figure out the best way to do this. and i found a plugin but it’s pretty complicated to use for a non-pro, as me. so, first, thanks.
and second, i’m still having a problem. i believe it can be with adding other function to functions.php, where i’m also defining the sidebars i’m using. so i’m getting this error, when trying to save the info on the new fields for a user. this is the error:
Warning: Cannot modify header information – headers already sent by (output started at /home7/layabozi/public_html/test/wordpress/wp-content/themes/Layabozi Reload/functions.php:44) in /home7/layabozi/public_html/test/wordpress/wp-includes/pluggable.php on line 868

I have no idea why it’s the pluggable.php reacting on this, and on functions line 44 is where your code begins.

do u think you can help me? or should i try to figure out that plugin to solve my nightmares? :/

I would like to add extra fields to the members profile section that will post the information to the dashboard for the admin.
Fields are as listed –
First name:
Last name:
Address: City: State: Zip:
Email:
Email Conformation:
Check-in date:
Checkout Date:
Event name:
Rate Paid:
Reservation made By:

I want it to post in the dashboard area for the admin. In members order. Most important is the email address. The purpose is to send out news letters and coupons to these email addresses. All my subscribers will be business owners only. Some sort of search would be a good idea to sort threw this info.
Thank You

You should probably use a mailing list plugin like MailPress to maintain your subscribers.

As for the extra fields on the profile page, I suggest adding them like in the code above.

a.poloczek

July 22, 2010 at 8:46 am

great article and some great answers here.
maybe here is someone who can help me… i am looking for a solution or tip to store a timestamp (user profile last modified at:) in the user_meta table every time a user updates his profile. in theory i thought a hidden field with a date function could solve my problem, but i really stuck at this point.

the best solution would be that all user profile informations will send per mail to the admin, if the user submit the profiles changes. If anybody has tips to solve that or has a working solution… please let me know. i would also pay for that… thanks

You can hook into an action when the user profile is saved and either add a field for the date or email the admin. If you are interested in having me build a plugin for you let me know by emailing me through the contact link above.

a.poloczek

July 23, 2010 at 4:54 am

Thanks for your quick response. I am interested. Did you get my private message? Thanks for your time and maybe help.

great post! in some wordpress i work, but in one of my websites, it was this erro: Warning: Cannot modify header information – headers already sent by (output started at /home/jc2esportes/www/site/wp-content/themes/organic_magazine/functions.php:111) in /home/jc2esportes/www/site/wp-includes/pluggable.php on line 890

It works for me with wordpress 3.0.4, the current latest version. Thanks so much for the tutorial! Stefan, did your functions.php already have code in it? If so, did you remove the first and last lines of code from the example before you pasted it in?

Jim Carey

December 10, 2010 at 5:22 pm

Hi,

would like to have a custom field (checkbox) for each user that the user can see (or maybe not even see) but NOT edit – but admin can see AND edit that I can then interrogate in another plugin. Admmin could set this on registration maybe and update subsequently if needed (but user can’t – or even can’t see)

Does anyone have any suggestions on how I would accomplish this ?

Jim

Fabio Salomoni

December 16, 2010 at 4:18 am

Hi, such a very interesting article! I have a problem: how to implement a way to check values that users insert and block the procedure in case some values miss or are wrong?

You can sanitize the submitted values in the save_extra_user_profile_fields() function.

Joanna

December 23, 2010 at 8:40 am

hi and thanks a lot for this information,
i have add a checkbox in user profile page that save the multi selected options in database but i try to list this selections in a template file but it returns an Array as text,
how i can call the selected checkboxes?

Have you assigned your checkboxes a value? If not, they will only have a value of “on” if they have been checked, and nothing if not. Are you using the the_author_meta() to retrieve the data? Have you added the User ID?