Support » Plugins » Walkthrough: Add a field to the registration page

  • You can see the actual code examples here:

    I’m using WP 2.0.2 and I wanted to add a field to the registration page to collect people’s phone numbers.

    First, I added a user_phone field to the wp_users table in my mysql database.

    Second, I altered wp-register.php. I added a Phone field to the page that posted to user_phone. I also added a $user_phone variable to the ‘register ‘ case and where the wp_create_user function is called.

    Third, I altered includes/registration-functions.php. I added the $user_phone variable to the wp_insert_user function, the wp_create_user function, and the create_user function and their database queries.

    Finally, I wanted to receive the users phone # in the “New User Registration” email. To do that I edited includes/pluggable-functions.php. Now the wp_new_user_registration function stipslashes for $user_phone and ads it to the message.

    I hope this helps some other WPers!

Viewing 5 replies - 1 through 5 (of 5 total)
  • Thanks! I was just looking into how to do this, I want to use first_name and last_name and then make a username from those and keep it hidden. Username won’t mean anything to most of the visitors to my WordPress site, it’d only serve to annoy and confuse.

    So near! how do I insert values into a wp_usermeta table?

    The benefit to having a username field is that it can be unqiue to each person that visits your site. If you are only using first and last name then you may run into a situation where 2 or more people with the same name are trying to register. Of course, the users could just alter their names for the sake of registering but this would probably be more confusing than just coming up with a unique username in the 1st place. It is quite easy to add first_name and last_name fields though using the method I described.

    For what I was doing I didn’t have to alter wp_usermeta so I don’t have any experience with that.


    This is the function i use in all my custom signup forms to allow for extra feilds to be attached to users.

    This add’s it to wp_usermeta table instead of wp_users, which i belive is the way WP wanted people to do it

    Bugsy … i cannot seem to find the file “addfield.txt”.

    Has it been removed?


Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Walkthrough: Add a field to the registration page’ is closed to new replies.