How do I update a user profile with entity_metadata_wrapper()? I got an error while updating user profile data such as name,password and email. I am using entity_metadata_wrapper() for processing update.


  exception 'EntityMetadataWrapperException' with message 'Unknown data property original.' in C:\xampp\htdocs\phone_bay\sites\all\modules\entity\includes\entity.wrapper.inc:335\nStack trace:\n#0 


This is my code.

require './includes/password.inc';
function commerce_services_user_update($uid, $data, $flatten_fields) {
    $user = user_load($uid);
    $wrapper = entity_metadata_wrapper('user', $user);
    dpm($wrapper-&gt;value());

    $name = $data['name'];
    $password = $data['password'];
    $email = $data['email'];

    if ($name != null) {
        $wrapper -&gt; name  = $name;
    }
    if($password != null){
        $wrapper -&gt; pass = user_hash_password($password);
    }
    if ($email != null) {
        $wrapper -&gt; mail = $email;
    }

    try {       
        user_save($wrapper);
        $message = "successessfully update!";
    } catch (Exception $e) {
        $message = "not success! -&gt; ". $e;
    }

    $reply = (array('status' =&gt; $status,'message' =&gt; $message));
    return $reply;
}
Since you are using an entity wrapper, you must use $entity-&gt;save to save the updated user object. In your case, use $wrapper-&gt;save.
user_save() can be used when the user entity is loaded using user_load().