These few months, I’ve been playing around with various parts of WordPress theming. It was no easy task as I’m used to how Expression Engine allows me to do most of the stuff I needed without much PHP knowledge needed.
One part that I’ll try to customize most of the time, is the registration page of my WordPress installation itself. Here, I’ll show you how to add a field to the WordPress registration form by leveraging the useful Cimy User Extra Fields plugin.
First off, let’s start with downloading Cimy User Extra Fields, upload to your WordPress plugin folder and activate it. Once you’ve done that, you should see a new options aptly named Cimy User Extra Fields under Settings.
Next we need to add a new field on the registration form that allows the user to select the role of their choosing.
Once you’ve added the field and save changes, check your registration page and you should see something like the ones below.
Linking it all up
Now that’s done, we’ll need to include the code inside our functions.php file. I was having troubles figuring out how to do this at first, but managed to find this article. In that article, it shows us how to do something similar with the use of URL parameters.
We’ll need to modify a bit on the code to get it working with our dropdown field though. Below is the modified code, courtesy of my talented friend Rizal.
|1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23||
And there you have it! Now all users registered to your WordPress site will be assigned a role of their choosing automatically.