基于此声明。。。
注意:我希望他们名为“我的帐户”的个人资料显示在导航栏上
。。。还有你描述的其他部分,我认为你想要的不是真正拥有“只有登录的成员”的页面。尽管问题的标题不同,但听起来您需要一个显示当前用户个人资料的页面,这只对登录用户有意义,但与标题所暗示的有所不同。假设解释是正确的。。。
应该是这样的:
<?php
/**
* Template Name : CurrentProfile
*/
if (is_user_logged_in()) {
global $current_user;
get_currentuserinfo();
// now you should have a data in $currentuser;
// basically the *_users table data for the current user; see the Codex
// get additional user data if desired
$umeta = get_user_meta($current_user->ID);
// now you have the *_usermata data for the current user
} else {
// user is not logged in
// do something or nothing as you please
}
现在从后端创建一个页面,并将此模板分配给它。现在出现菜单问题。
菜单问题
为该页面分配菜单项很容易,但您可能根本不想让未登录int的用户看到它。最简单的解决方案是CSS。如果主题使用
body_class
功能正常
<body
页面的标记将具有
logged-in
对于登录的用户,请使用样式表在默认情况下隐藏菜单,并仅在具有
logged-in
在
<body>
标签我不能把CSS写下来,这可能取决于你的主题。
这不是唯一的解决方案。您可以为菜单创建一个自定义的助行器,也可以挂接到助行器中,但CSS解决方案是最简单的,应该已经足够了。
其他参考资料
http://codex.wordpress.org/Function_Reference/get_currentuserinfohttp://codex.wordpress.org/Function_Reference/get_user_meta