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;

2 Answers 2


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

user_save() can be used when the user entity is loaded using user_load().

  • 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)
    Commented Jan 7, 2016 at 8:28
  • 1
    Have you given correct values in the user object? Because mail validation also happens here.
    – Manikandan
    Commented Jan 7, 2016 at 10:25

The user entity needs to be also saved. The full code for changing the username and the email address is then the following one.

$wrapper->name->set('Jean louis');
$wrapper->mail->set('[email protected]');

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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