So I added an extra table to my db to hold some other user info (i.e. firstname,lastname ...) ... I am trying to use hook_user but I have some questions:
1) Do I use hook_alter_form to add my extra form fields? or hook_user(op="form")? If the latter, how exactly? If the former, how do I set the pre-set values when the user goes to edit his/her profile?
2) For the moment I am using hook_alter_form ... when I do this, all my extra info gets stored in the users tbl (data field) why? I thought that if I just cleared that extra info in my hook_user(op=save) handler (see below) then that wouldn't happen
function ds_save_user($edit, $user, $category){
// create unix timestamp for bday
$birthday = mktime(0,0,1,$edit['month'],$edit['day'],$edit['year']);
// check if user exists in user_info tbl
$query = "SELECT uid FROM {users_info} WHERE uid=%d";
if(db_result(db_query($query,$edit['uid']))){
// UPDATE
$query = "UPDATE {users_info} SET firstname='%s',lastname='%s',gender='%s',birthday= %d,zip='%s' WHERE uid=%d";
$result = db_query($query,$edit['firstname'],$edit['lastname'],$edit['gender'],$birthday,$edit['zip'],$edit['uid']);
}else{
// INSERT NEW
$query = "INSERT INTO {users_info} (uid,firstname,lastname,gender,birthday,zip) VALUES (%d,'%s','%s','%s',%d,'%s')";
$result = db_query($query,$edit['uid'],$edit['firstname'],$edit['lastname'],$edit['gender'],$birthday,$edit['zip']);