I'm trying to find out how to add user details to a separate table using PHP and unique meta data to it. I 'd rather do this when a user has posted to the table wp users and wp usermeta. I use the auction plugin WooCommerce and the theme Salient.
My code
add_action('user_register', 'save_to_donors',10,1);
function save_to_donors( $user_id ) {
$single = true;
$user_email = get_userdata($user_id);
$fn= get_user_meta($user_id, 'first_ name', $single );
$ln= get_user_meta($user_id, 'last_name', $single );
$em= $user_email->user_email;
$ph= get_user_meta($user_id, 'billing_phone', $single );
$ad= get_user_meta($user_id, 'billing_address_1', $single );
$ci= get_user_meta($user_id, 'billing_city', $single );
$st= get_user_meta($user_id, 'billing_state', $single );
$zi= get_user_meta($user_id, 'billing_postcode',$single );
$do= get_user_meta($user_id, '_money_spent', $single );
$sql = "INSERT INTO donors (user_id,first_name,last_name,email," .
"phone,address,city,state,zip,amount_donated)".
"VALUES('$user_id','$fn','$ln','$em','$ph','$ad','$ci','$st','$zi','$do')";
$result = mysqli_query($wpdb, $sql) or die('Write Error!');
}