I am having trouble inserting logged-in user data, using the 'user_register' hook. The following code inserts a row in the database, but only inserts the 'email' column.
function nuevoPostulante()
{
global $wpdb;
$tablaPostulante = $wpdb->prefix . 'postulante';
$current_user = wp_get_current_user();
$wpdb->insert(
$tablaPostulante,
array(
'dni' => $current_user->user_login,
'nombre' => $current_user->display_name,
'email' => 'test@insert.com',
)
);
}
add_action('user_register', 'nuevoPostulante');
Columns with values taken from '$ current_user' are empy, the insert do not seem to take data from the array.
I think it's a scope problem, I still don't understand how to fix it. Somebody could help me? Thank you!