How do I add custom fields to the registration form on my store if I am using Product Vendors?

As the internet evolves, so does the information you need from customers when they register with your store. It’s likely that a default registration form will cover everything you want to gather when some signs up. For example, having social media usernames can help you keep in touch, but those fields are not automatically part of the default form.

It’s also important that you be able to add the same information if you manually create a user within the dashboard itself. Adding and modifying a bit of code in your theme’s function.php file will allow you to do both.

Let’s break down this code a bit.

Lines 1 to 50, adds the two new fields to the taxonomy in the Product Vendors form. This allows you to specify their Facebook or Twitter URLs as to manually create or edit a vendor in the WP-Admin.

Lines 51 to 76, validates and saves the fields in the database.

Lines 78 to 91, adds the same fields to the registration form. You can show this on a page by using the shortcode:

[wcpv_registration]

The fields will appear after the Vendor Description fields. These are shown at the end of the form right before the Submit button.

Lastly, lines 93 to 98 saved the fields in the vendor taxonomy.

Of course this is a simple example with two text fields. You could easily add any kind of fields you want, even more than 2.

This is just a simple example with two text fields, as you can imagine you can add any kind of fields, and as many as you want.

 

Be Sociable, Share!

Author Bio

About the Author: AJ Morris

AJ Morris is the Product Manager for Liquid Web’s Managed WordPress/WooCommerce Hosting. He’s been involved in the WordPress community for over a decade focusing on building, designing and launching WordPress websites and businesses.

Here's 75 % off, Launch a New VPS Today. Find out why 30,000 customers have chosen our Best-in-Class Performance & 24x7 Heroic Support