我有一个带有表单的 WordPress 网站。我正在尝试使用 WordPress 的登录名自动填充表单中的名称字段。我怎样才能做到这一点?我尝试了一些php get current user name
,但没有奏效。任何帮助将不胜感激。
<?php
//get current username
global $ current_user;
$current_user=wp_get_current_user();
$cuname=$current_user-> user_name; ?>
// in the form
value="<?php echo $cuname; ?>" read only