rendered paste body$previous_database = db_set_active('seperate_db')
db_set_active($previous_database);
function swap_db_form_alter($form_id, &$form) {
// Send profile data to external database.
if (isset($form['type']) && 'user-edit' == $form_id) {
if (db_result(db_query("SELECT fid FROM {profile_fields} WHERE username = '%s'". $query_suffix, $args2))) {
$form['#submit']['send_to_db'] = array();
}
}
}
function send_to_db($user_profile, $mode) {
$name = $user_profile->username;
$user = db_fetch_object(db_query("
SELECT uid
FROM {JOIN_TABLE_USERS}
WHERE exid = '%s'",
$name
));
if ($user) {
$node->field_age[0]['value'] = $user_profile->age;
$node->field_location[0]['value'] = $user_profile->location;
$exists = db_fetch_object(db_query("
SELECT nid
FROM node n
WHERE n.type = 'user_profile'
AND n.uid = %d",
$user->uid
));
if ($exists) $node->nid = $exists->nid;
if ($mode == 1) node_save($node);
return $output;
}
db_set_active();