user\\u register操作允许您在新用户添加到数据库后立即访问其数据。用户id作为参数传递给hook。
因此,您希望在用户注册时为用户插入记录,您可以修改代码,如下所示:
add_action( \'user_register\', \'nuevoPostulante\', 10, 1 );
function nuevoPostulante( $user_id ) {
global $wpdb;
$tablaPostulante = $wpdb->prefix . \'postulante\';
$current_user = get_user_by( \'ID\', $user_id ); // You can use get_userdata( $user_id ) instead of get_user_by() both can be work perfectly suite your requirement.
$wpdb->insert(
$tablaPostulante,
array(
\'dni\' => $current_user->user_login,
\'nombre\' => $current_user->display_name,
\'email\' => \'[email protected]\',
)
);
}