【发布时间】:2016-05-30 08:15:39
【问题描述】:
我想在登录后为用户显示,而不是默认单词“我的帐户”我想显示用户名,我尝试了此代码,但它没有显示任何内容!
它似乎无法识别位于以下文件中的变量$current_user:wp-content/themes/themeName/framework/functions/woo-account.php
printf( __( '%s', 'wpdance' ),$current_user->user_lastname);
原来是:
printf( __( 'My Account', 'wpdance' ));
我还尝试使用此代码获取所有内容:
<?php global $current_user;
get_currentuserinfo();
echo 'Username: ' . $current_user->user_login . "\n";
echo 'User email: ' . $current_user->user_email . "\n";
echo 'User level: ' . $current_user->user_level . "\n";
echo 'User first name: ' . $current_user->user_firstname . "\n";
echo 'User last name: ' . $current_user->user_lastname . "\n";
echo 'User display name: ' . $current_user->display_name . "\n";
echo 'User ID: ' . $current_user->ID . "\n";
?>
但是User first name: 和User last name: 是空的!
有人有什么建议或想法吗?
谢谢你!
【问题讨论】:
-
你试过
printf( __( $current_user->user_lastname, 'wpdance' ));吗? -
我只是这样做了,但它不起作用!
标签: php wordpress woocommerce account userinfo