0

我有一个带有表单的 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
4

1 回答 1

0

你有user_name什么时候应该是user_login

$cuname = $current_user->user_login

于 2016-01-07T03:59:53.497 回答