user_register 动作挂钩在执行时没有任何输出,因此您无法从中回传任何内容。
如果要调试此函数的输出,请将其转储到错误日志中。
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);