Support » Plugin: Theme My Login » Allow user to select the role during the registration

Viewing 4 replies - 1 through 4 (of 4 total)
  • I also tried the below code but no luck….

    <p class="tml-submit-wrap">
                            <label for="select-user-role">Please select your role</label>
                            <select id="select-user-role" name="select-user-role" class="input select">
                                <option value="author">Author</option>
                                <option value="reviewer">Reviewer</option>
                            </select>
    </p>
    function tml_new_user_registered( $user_id ) {
      $u = new WP_User(  $user_id );
    
        if($_REQUEST['select-user-role']=='reviewer') {
          $u->remove_role( 'subscriber' );
          $u->add_role( 'editor' );
        }
    }
    add_action( 'user_register', 'tml_new_user_registered' );
    
    function myplugin_user_register( $user_id ) {
    
       update_user_meta( $user_id, 'role', $_POST['select-user-role'] );
    }
    add_action( 'user_register', 'myplugin_user_register' );

    Thanks

    Plugin Author Jeff Farthing

    (@jfarthing84)

    Either of those should be working. Have you verified that those callbacks are actually being run? Try throwing a die('test'); in there or some other way to verify that the callbacks are actually firing.

    Hi,

    Thanks so much for the reply. I didn’t get chance to solve this. So, I used another plugin for the site.

    Thanks Again

    Hi Priyadilsha

    I have a similar requirement – namely, using a couple of select dropdowns in registration form. Please let me know which plugin you used to solve the problem. Was it along with “theme my login” or as replacement?

    Please do reply. Thanks & regards.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Allow user to select the role during the registration’ is closed to new replies.