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);

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

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

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

    $reply = (array('status' => $status,'message' => $message));
    return $reply;

Since you are using Entity wrapper, you must use $entity->save to save your updated user object. In your case, use $wrapper->save.

user_save can be used if user is load using user_load api.

  • Not ok yet after changing code to $wrapper -> save(); exception still occurs. (exception 'EntityMetadataWrapperException' with message 'Invalid data value given. Be sure it matches the required data type and format.' in C:\\xampp\\htdocs\\phone_bay\\sites\\all\\modules\\entity\\includes\\entity.wrapper.inc:737\nStack trace:\n#0) – SAWAUNG Jan 7 '16 at 8:28
  • Have you given correct values in the user object? Because mail validation also happens here. – Manikandan Jan 7 '16 at 10:25

Just for the sake of having a complete answer :

$wrapper->name->set('Jean louis');

Instead of assigning value to the variable, you can set the value using set() method of wrapper, what you can do is:


This will save the value, you will not have to issue command of user_save

  • This will not save the value if you don't call $wrapper->save(); – Thony Aug 20 at 10:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.