title: WP wp_update_user($userdata) Error
body: <p>I am working with WordPress 3.9 and Woocommerce in <code>templates/../my-account.php</code>. I did not like the default my-account page and wanted the user to be able to edit specific settings so I set it up so the user can change their username, email, or password. That was the goal at least haha.</p>
  
  <p>In the debugging process, I found the problem was with <code>$user_id = wp_update_user( $userdata );</code> . <code>is_wp_error($user_id)</code> returns <code>false</code>. When I use <code>wp_get_current_user();</code> I am able to <code>echo</code> <code>user_email</code>, for example, and the user's email is displayed. I'm pretty sure I created the <code>$userdata</code> array correctly, so what do I need to change to be able to update the user's settings?</p>
  
  <p>I could be making a mistake, but to my knowledge I'm doing everything according to the <a href="http://codex.wordpress.org/Function_Reference/wp_update_user" rel="nofollow">codex docs</a>.</p>
  
  <p>Here's my code for my-account.php if you need other code or more information I can supply. Thank you for any help.</p>
  
  <pre><code>&lt;?php
  /**
   * My Account
   */
  
  global $woocommerce;
  global $current_user;
  ?&gt;
  &lt;style type="text/css"&gt;
      #edit-account-settings { font-size: 1.2em; width: 280px; }
      #edit-account-settings input { width: 100%; }
      #edit-submit { font-size: 1em; }
  &lt;/style&gt;
  &lt;?php
  
  wp_get_current_user();
  if(is_null($current_user)) {
      echo 'Sorry, you are not logged in. '.wp_loginout();
  } else {
      $php_option = false;
      $fName = $current_user-&gt;first_name;
      $lName = $current_user-&gt;last_name;
      $username = $current_user-&gt;user_login;
      $email = $current_user-&gt;user_email;
      print '&lt;div id="account-settings"&gt;&lt;h2&gt;Welcome '.$fName.' '.$lName.'&lt;/h2&gt;';
      print '&lt;p style="font-size: 1.4em;"&gt;User Name: '.$username.'&lt;/p&gt;';
      print '&lt;p style="font-size: 1.4em;"&gt;Email: '.$email.'&lt;/p&gt;';
      print '&lt;p style="font-size: 1.4em;"&gt;Password: ********&lt;/p&gt;';
      print '&lt;a id="edit-account-settings" href="#" onclick="edit_settings();"&gt;Change your account settings&lt;/a&gt;&lt;/div&gt;';
  }
  ?&gt;
  
  &lt;script&gt;
      function edit_settings() {
          //alert("inside onclick event");
          var username = &lt;?php echo json_encode($username); ?&gt;;
          var email = &lt;?php echo json_encode($email); ?&gt;;
          var data = '&lt;p style="font-size: 1.2em;"&gt;To change your settings, enter the new value in the appropriate text field&lt;/p&gt;';
          data += '&lt;p style="font-size: 1.2em;"&gt;If do not want to change your password, enter your current password twice.&lt;/p&gt;';
          data += '&lt;p style="font-size: 1.2em;"&gt;If you want your other settings to remain the same, leave the fields as they are and submit.&lt;/p&gt;';
          data += '&lt;form id="edit-account-settings" name="edit-account-settings" method="post" action=""&gt;';
          data += '&lt;label for="un"&gt;User Name: &lt;/label&gt;&lt;input type="text" id="un" name="un" value="'+username+'" maxlength="16" required /&gt;';
          data += '&lt;label for="email"&gt;Email: &lt;/label&gt;&lt;input type="email" id="em" name="em" value="'+email+'" maxlength="32" required /&gt;';
          data += '&lt;br /&gt;&lt;br /&gt;&lt;input type="password" id="p1" name="p1" value="" placeholder="Enter a new password" maxlength="16" required /&gt;';
          data += '&lt;br /&gt;&lt;br /&gt;&lt;input type="password" id="p2" name="p2" value="" placeholder="Re-enter password" maxlength="16" required /&gt;';
          data += '&lt;br /&gt;&lt;br /&gt;&lt;input type="submit" id="edit-submit" name="edit-submit" value="Submit Changes" /&gt;';
          data += '&lt;/form&gt;&lt;/div&gt;';
          var elem = document.getElementById("account-settings");
          elem.innerHTML = data;
      }
  &lt;/script&gt;
  
  &lt;?php
      if (isset($_POST['em']) &amp;&amp; $_POST['em'] != $email &amp;&amp; $_POST['em'] != "") {
          $em = $_POST['em'];
          $userdata = array(
              'user_email' =&gt; $em
          );
  
          if (!empty($userdata) || isset($userdata['user_email'])) {
              $user_id = wp_update_user( $userdata );
              if(is_wp_error($user_id)) {
                  echo "&lt;p style='color: #FF0000;'&gt;Error: Sorry your settings could not be updated. Please try again in a minute.&lt;/p&gt;";
              } else {
                  echo "&lt;p style='color: #00FF00;'&gt;Congradulations! Your settings have been updated.&lt;/p&gt;";
              }
          } else {
              echo "&lt;p&gt;$userdata is null or undefined&lt;/p&gt;";
          }
      } else {
          echo "&lt;p&gt;Your email address is the same&lt;/p&gt;";
      }
  ?&gt;
  
  &lt;?php do_action('woocommerce_before_my_account'); ?&gt;
  
  &lt;?php if ($downloads = $woocommerce-&gt;customer-&gt;get_downloadable_products()) : ?&gt;
  &lt;h2&gt;&lt;?php _e('Available downloads', 'woocommerce'); ?&gt;&lt;/h2&gt;
  &lt;ul class="digital-downloads"&gt;
      &lt;?php foreach ($downloads as $download) : ?&gt;
          &lt;li&gt;&lt;?php if (is_numeric($download['downloads_remaining'])) : ?&gt;&lt;span class="count"&gt;&lt;?php echo $download['downloads_remaining'] . _n('&amp;nbsp;download remaining', '&amp;nbsp;downloads remaining', $download['downloads_remaining'], 'woocommerce'); ?&gt;&lt;/span&gt;&lt;?php endif; ?&gt; &lt;a href="&lt;?php echo esc_url( $download['download_url'] ); ?&gt;"&gt;&lt;?php echo $download['download_name']; ?&gt;&lt;/a&gt;&lt;/li&gt;
      &lt;?php endforeach; ?&gt;
  &lt;/ul&gt;
  &lt;?php endif; ?&gt; 
  
  &lt;h2&gt;&lt;?php _e('Recent Orders', 'woocommerce'); ?&gt;&lt;/h2&gt;
  &lt;?php woocommerce_get_template('myaccount/my-orders.php', array( 'recent_orders' =&gt; $recent_orders )); ?&gt;
  
  &lt;h2&gt;&lt;?php _e('My Address', 'woocommerce'); ?&gt;&lt;/h2&gt;  
  &lt;p class="myaccount_address"&gt;&lt;?php _e('The following addresses will be used on the checkout page by default.', 'woocommerce'); ?&gt;&lt;/p&gt;
  &lt;?php woocommerce_get_template('myaccount/my-address.php'); ?&gt;
  
  &lt;?php
  do_action('woocommerce_after_my_account');
  </code></pre>