WordPress.org

Ready to get started?Download WordPress

Forums

Walkthrough: Add a field to the registration page (6 posts)

  1. BigBugsy
    Member
    Posted 8 years ago #

    You can see the actual code examples here:

    http://www.austinapartmentspecials.com/addfield.txt

    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!

  2. neeKlamy
    Member
    Posted 7 years ago #

    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.

  3. neeKlamy
    Member
    Posted 7 years ago #

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

  4. BigBugsy
    Member
    Posted 7 years ago #

    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.

  5. Phunky
    Member
    Posted 7 years ago #

    update_usermeta(ID,'META_NAME','META_VALUE');

    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

  6. DesignPastor
    Member
    Posted 7 years ago #

    Bugsy ... i cannot seem to find the file "addfield.txt".

    Has it been removed?

    THanks

Topic Closed

This topic has been closed to new replies.

About this Topic