Sync user meta data to a second database
I need to sync data from the wp_users and usermeta databases to a second table upon registration. I have accomplished the wp_user part successfuly by placing the following code in my functions file:
function add_to_YjT_bookly_customers($user_id) {
global $wpdb;
$user_info = get_userdata($user_id );
$wpdb-insert( 'YjT_bookly_customers', array('full_name' = $user_info-user_login,'wp_user_id' = $user_info-ID,'email' =$user_info-user_email,'first_name' = $user_info-first_name), array('%s', '%s', '%s', '%s') );
}
add_action( 'user_register', 'add_to_YjT_bookly_customers');```
But I also want to sync data from the usermeta db, specifically the first_name and last_name. You can see from the code above that the target db is Yjt_bookly_customers and that I tried (hoped) that the first_name would also sync. And while the user_login, id, and pw sync'ed, the first_name did not. I guess the metadata is not covered by the $user_id variable or I am simply not accessing it correctly. So my question is what code would I need to add to also sync the first_name, last_name fields from the usermeta table to successfully sync those as well at registration submission.