$current_user
未在该函数的作用域中声明。您希望修改代码,使其更像这样:
function get_form($atts) {
$current_user = wp_get_current_user();
return \'<form method="post" action="">
<input type="input" name="myinput" value=""></input>
<input type="hidden" name="myvar" value="\' . $current_user->ID . \'">
</form>\';
}
add_shortcode(\'myshortcode\', \'get_form\');