From fc70124a3efbe8dd34c24c16efbabdfdacf1db87 Mon Sep 17 00:00:00 2001
From: "richard.alexander.allen@gmail.com" <richard.allen@timeinc.com>
Date: Thu, 26 Sep 2013 01:59:22 -0400
Subject: [PATCH] Issue #1921894 by sonictruth, Alexander Allen:
 entity_metadata_form_user() builds incorrect form.

---
 modules/callbacks.inc | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/modules/callbacks.inc b/modules/callbacks.inc
index e4da18f..5da9c86 100644
--- a/modules/callbacks.inc
+++ b/modules/callbacks.inc
@@ -896,10 +896,18 @@ function entity_metadata_form_comment($comment) {
  * Callback to get the form of a user account.
  */
 function entity_metadata_form_user($account) {
-  // Pre-populate the form-state with the right form include.
+  // If $account->uid is set then we want a user edit form.
+  // Otherwise we want the user register form.
+  if (isset($account->uid)) {
+    $form_id = 'user_profile_form';
+    form_load_include($form_state, 'inc', 'user', 'user.pages');
+  }
+  else {
+    $form_id = 'user_register_form';
+  }
+  
   $form_state['build_info']['args'] = array($account);
-  form_load_include($form_state, 'inc', 'user', 'user.pages');
-  return drupal_build_form('user_profile_form', $form_state);
+  return drupal_build_form($form_id, $form_state);
 }
 
 /**
-- 
1.7.11.1

