I have a website that has customers and vendors. What is the proper way to let the new registered user choose between two specific roles the way they would like to have? Do they want to be as a customers and buy things or do they want to start selling.

I’m dreaming of a registration page where you could actually put your username, email and then select the role role. Don’t know is this possible to do. Please see the attached picture.

Customer or Vendor picture

1 Answer 1


see register_form action hook for modifying the registration form

add_action( "register_form", function() {
    $html = '<p>'.__('Do you want to buy or sell?<br>Choose your role').'</p>';
    $html .= '<p>';
        $html .= '<label for="_customer"><input type="radio" name="user_role" id="_customer" value="customer"/>'.__('Customer').'</label><br>';
        $html .= '<label for="_vendor"><input type="radio" name="user_role" id="_vendor" value="_vendor"/>'.__('Customer').'</label>';
    $html .= '</p>';
    echo $html;
} );

you can use user_register action to save selected user role.

add_action( "user_register", function( $user_id ) {
    $allowed = array( 'customer', 'vendor' );
    if( isset( $_POST['YourFieldName'] ) && in_array( $_POST['YourFieldName'], $allowed ) ){
        $user = new WP_User( $user_id );
} );

check WP_User class reference document for more information;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.