title: User Role Select on Woocommerce Registration Stopped Working
body: <p>I use a drop down menu to select between two user roles on my Woocommerce registration form. After updating to Woocommerce 3.0.8 the drop down menu stopped working and I cannot figure out why. Below is the code I've been using. Any ideas?</p>
  
  <pre><code>// Add two new roles.
  add_role('dealer', 'Dealer', array( 
  'delete_posts' =&gt; false,
  'delete_published_posts' =&gt; false,
  'edit_posts' =&gt; false,
  'edit_published_posts' =&gt; false,
  'publish_posts' =&gt; false,
  'read' =&gt; true,
  'upload_files' =&gt; true,
  'edit_users' =&gt; false
  ));
  add_role('distributor', 'Distributor', array(
  'delete_posts' =&gt; false,
  'delete_published_posts' =&gt; false,
  'edit_posts' =&gt; false,
  'edit_published_posts' =&gt; false,
  'publish_posts' =&gt; false,
  'read' =&gt; true,
  'upload_files' =&gt; true,
  'edit_users' =&gt; false
  ));
  add_action('register_form','role_registration_form');
  function role_registration_form(){
  $wp_roles = new WP_Roles();
  $wp_roles-&gt;use_db = true;
  $role_names = $wp_roles-&gt;get_names();
  
  foreach( $role_names as $role_name ) {
      // Ensure that the options exclude default Wordpress roles
      if ( ($role_name !== 'Administrator') and ($role_name !== 'Editor') and ($role_name !== 'Author') and ($role_name !== 'Contributor' ) and ($role_name !== 'Subscriber') and ($role_name !== 'Customer') and ($role_name !== 'Shop Manager')) {
          //  Role value below needs to be in lowercase only
          $role_option .= "&lt;option value='".strtolower($role_name)."'&gt;";
          $role_option .= $role_name;
          $role_option .= "&lt;/option&gt;";
      }
  }
  $html = '
  &lt;style type="text/css"&gt;
          #role {
          background:#FBFBFB none repeat scroll 0 0;
          border:1px solid #E5E5E5;
          font-size:15px;
                      color:#3a3a3a;
          margin-bottom:16px;
          margin-right:6px;
          margin-top:2px;
          padding:3px;
          width:35%;
      }
  &lt;/style&gt;
  
  &lt;div width="100%"&gt;
      &lt;p&gt;
          &lt;label style="display: block; margin-bottom: 5px;"&gt;' . __('Are you a Dealer or Distributor?', 'Role') . '
              &lt;select id="role" name="role" class="input"&gt;
              ' . $role_option . '
              &lt;/select&gt;
          &lt;/label&gt;
      &lt;/p&gt;
  &lt;/div&gt;
  ';
  echo $html;
  }
  add_action('user_register', 'register_role');
  function register_role($user_id, $password="", $meta=array()) {
  $userdata = array();
  $userdata['ID'] = $user_id;
  $userdata['role'] = $_POST['role'];
  // allow if a role is selected
  if ( $userdata['role'] ){
    wp_update_user($userdata);
  }
  }
  add_action( 'show_user_profile', 'role_selection_field' );
  add_action( 'edit_user_profile', 'role_selection_field' );
  function role_selection_field( $user ) {
  $wp_roles = new WP_Roles();
  $wp_roles-&gt;use_db = true;
  $role_names = $wp_roles-&gt;get_names();
  foreach( $role_names as $role_name ) {
      if ( ($role_name !== 'Administrator') and ($role_name !== 'Editor') and ($role_name !== 'Author') and ($role_name !== 'Contributor' ) and ($role_name !== 'Subscriber') and ($role_name !== 'Customer') and ($role_name !== 'Shop Manager')) {
          if ( !empty( $user-&gt;roles ) &amp;&amp; is_array( $user-&gt;roles ) ) {
              foreach ( $user-&gt;roles as $role ) {         
                  if ( strtolower($role_name) == $role ) {
                      $role_option .= "&lt;option value='".strtolower($role_name)."' selected='selected'&gt;";
                      $currentrole = strtolower($role_name);
                  } else {
                      $role_option .= "&lt;option value='".strtolower($role_name)."'&gt;";
                  }
  
                  $role_option .= $role_name;
                  $role_option .= "&lt;/option&gt;";
              }
          }
      }
  }
  ?&gt;
  
  &lt;?php }
  
  add_action( 'personal_options_update', 'save_role_selection_field' );
  add_action( 'edit_user_profile_update', 'save_role_selection_field' );
  function save_role_selection_field( $user_id ) {
  //if ( !current_user_can( 'edit_user', $user_id ) ) { return false; }
  update_user_meta( $user_id, 'role', $_POST['role'] );
  
  $user = new WP_User( $user_id );
  // Remove role
  $current_user_role = get_current_user_role();
  
  $user-&gt;remove_role( $current_user_role );
  // Add role
  $user-&gt;add_role( $_POST['role'] );
  }
  function get_current_user_role () {
  global $current_user;
  get_currentuserinfo();
  $user_roles = $current_user-&gt;roles;
  $user_role = array_shift($user_roles);
  return $user_role;
  };
  
  ?&gt;
  </code></pre>