User register hook is not working in woocomerce register form

user_register action hook is performed without any output, therefore you can’t echo anything from it.

If you’re looking to debug the output from this function, dump it to the error log.

function send_coupon_to_freshly_registered_user($user_id) {
        $user = get_user_by('id',$user_id); //new line
        $user_email = stripslashes($user->user_email); //changed line
        error_log( print_r( $user_email, true ) ); // print_r the variable to error log.
}
add_action('user_register', 'send_coupon_to_freshly_registered_user', 10, 1);

error code: 523