--- openid_cp_field.module.old 2010-02-12 14:22:38.934897633 -0300 +++ openid_cp_field.module.new 2010-02-12 14:21:35.446896053 -0300 @@ -318,11 +318,16 @@ if (empty($mapping)) { return; } - // If a profile already exists with any valid profile type, do nothing. - if (db_result(call_user_func_array('db_query', array("SELECT COUNT(*) FROM {node} WHERE uid = %d AND type IN (". db_placeholders($profile_types, 'text') . ")", $account->uid) + $profile_types)) > 0) { - return; - } + $profile = new StdClass(); + // If a profile already exists with any valid profile type, update the profile, else create a new one. + $nid = db_result(db_query("SELECT nid FROM {node} WHERE uid = %d AND type = '%s'", $account->uid, $type)); + if ($nid) { + $profile = node_load($nid); + } else { + $profile->uid = $account->uid; + $profile->type = $type; + } foreach ($mapping as $openid => $node) { $field = FALSE; if (module_exists('openid_client_ax')) { @@ -344,8 +349,6 @@ if (module_exists('auto_nodetitle')) { auto_nodetitle_set_title($profile); } - $profile->uid = $account->uid; - $profile->type = $type; node_save($profile); } }