user3776900
user3776900

Reputation: 29

Can I create a custom WordPress registration form?

I want to have in WordPress two kind of registration forms. The default one for let's say visitors users and a custom one for some more privileged users. How can I make the custom one? I especially need the part with the roles, the custom reg form will have another role for the users that will register to it. How can I do that? I think I need something like(it's just a fabulation, don't know the real functions from WordPress)

Example:

//the following variables will be a part of the form that will stand above this function
 add_user('$username','$mail','$location','$region','$role');
//where $role can be {1(subscribers),2(contrib.),3(authors),4(editor),5(admin)}

Can I do something like that?

Upvotes: 0

Views: 713

Answers (2)

ravalisri vasam
ravalisri vasam

Reputation: 1

You can install a webform module in wordpress. Selected an existing form and customize the fields as per your requirement.

Upvotes: 0

michaelrmcneill
michaelrmcneill

Reputation: 1163

You can use Gravity Forms to create your registration forms with the User Registration add-on and specify custom user meta (including roles.) If you would like to create a custom form without a plugin, you should not attempt to add users directly to the database, instead you should use the wp_create_user function. From the WordPress Codex:

The wp_create_user function allows you to insert a new user into the WordPress database. It uses the $wpdb class to escape the variable values, preparing it for insertion into the database. Then the PHP compact() function is used to create an array with these values. To create a user with additional parameters, use wp_insert_user().

Upvotes: 2

Related Questions