Add Roles During Registration
-
Hello!
Thank you for great plugin!
I’m trying to add Roles to Registration form like describe here https://www.jfarthing.com/development/theme-my-login/adding-extra-registration-fields/register-form.php
<p> <label for="role<?php $template->the_instance(); ?>"><?php _e( 'Role*', 'theme-my-login' ) ?></label> <select name="role" id="role<?php $template->the_instance(); ?>" class="input"> <option value="role1">Role 1</option> <option value="role2">Role 2</option> </select> </p>
and
theme-my-login-custom.phpfunction tml_registration_errors( $errors ) { if ( empty( $_POST['user_role'] ) ) $errors->add( 'empty_user_role', '<strong>ERROR</strong>: Please select your role.' ); return $errors; } add_filter( 'registration_errors', 'tml_registration_errors' ); function tml_user_register( $user_id ) { if ( !empty( $_POST['role'] ) ) update_user_meta( $user_id, 'role', $_POST['role'] ); } add_action( 'user_register', 'tml_user_register' );
At WP Settings I have default registration role is Role1. But after I added additional fields to registration form and select Role 2 during registration I still have Role 1 after registration is complete.
I will be appreciate for any help.
Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)
- The topic ‘Add Roles During Registration’ is closed to new replies.