站长百科 | 数字化技能提升教程 数字化时代生存宝典
首页
数字化百科
电子书
▼
建站程序
开发
服务器
办公软件
开发教程
▼
服务器教程
软件使用教程
运营教程
热门电子书
▼
CSS教程
WordPress教程
导航
程序频道
推广频道
网赚频道
人物频道
网站程序
网页制作
云计算
服务器
CMS
论坛
网店
虚拟主机
cPanel
网址导航
WIKI使用导航
WIKI首页
热点词条
最新资讯
网站程序
站长人物
页面分类
使用帮助
编辑测试
创建条目
网站地图
站长百科导航
站长百科
主机侦探
IDCtalk云说
跨境电商导航
WordPress啦
站长专题
网站推广
网站程序
网站赚钱
虚拟主机
cPanel
网址导航专题
云计算
微博营销
虚拟主机管理系统
开放平台
WIKI程序与应用
美国十大主机
编辑“
WordPress:Function Reference/get currentuserinfo
”
人物百科
|
营销百科
|
网赚百科
|
站长工具
|
网站程序
|
域名主机
|
互联网公司
|
分类索引
跳转至:
导航
、
搜索
警告:
您没有登录。如果您做出任意编辑,您的IP地址将会公开可见。如果您
登录
或
创建
一个账户,您的编辑将归属于您的用户名,且将享受其他好处。
反垃圾检查。
不要
加入这个!
== Description == == 描述 == Retrieves the information pertaining to the currently logged in user, and places it in the global variable <tt>$userdata</tt>. Properties map directly to the wp_users table in the database (see [[WordPress:Database Description#Table:_wp_users|Database Description]]). 返回关于当前登录的用户的信息并且将这个信息放置于全局变量<tt>$userdata</tt>中。属性直接映射到数据库中的wp_users表格(请看看[[WordPress:Database Description#Table:_wp_users|数据库描述]])。 Also places the individual attributes into the following separate global variables: 同时将单个的属性放置到下面分开的全局变量中: :* <tt>$user_login</tt> :* <tt>$user_level</tt> :* <tt>$user_ID</tt> :* <tt>$user_email</tt> :* <tt>$user_login</tt> :* <tt>$user_level</tt> :* <tt>$user_ID</tt> :* <tt>$user_email</tt> :* <tt>$user_url</tt> (User's website, as entered in the user's Profile) :* <tt>$user_url</tt>(用户的网站,输入进用户的基本资料) :* <tt>$user_pass_md5</tt> (A md5 hash of the user password -- a type of encoding that is very nearly, if not entirely, impossible to decode, but useful for comparing input at a password prompt with the actual user password.) :* <tt>$user_pass_md5</tt>(用户密码的md5 hash-编码的一种方式,几乎不能够解码,但还不是完全不能够,对于使用真正的用户密码来比较密码提示中的输入内容,很有用。) :* <tt>$display_name</tt> (User's name, displayed according to the 'How to display name' User option) :* <tt>$display_name</tt> (用户的名称,根据'怎样显示名称'用户选项,显示) == Usage == == 用法== %%% <?php get_currentuserinfo(); ?> %%% %%% <?php get_currentuserinfo(); ?> %%% == Examples == === Default Usage === == 例子 == ===默认用法=== The call to <tt>get_currentuserinfo()</tt> places the current user's info into <tt>$userdata</tt>, where it can be retrieved using member variables. 调用<tt>get_currentuserinfo()</tt>,将当前用户的信息放置到<tt>$userdata</tt>,使用member变数,可以重新得到用户的信息。 <?php global $userdata; get_currentuserinfo(); echo('Username: ' . $userdata->user_login . "\n"); echo('User level: ' . $userdata->user_level . "\n"); echo('User ID: ' . $userdata->ID . "\n"); ?> <div style="border:1px solid blue; width:50%; padding:10px">Username: Zedd<br /> User level: 10<br /> User ID: 1</div> <?php global $userdata; get_currentuserinfo(); echo('Username: ' . $userdata->user_login . "\n"); echo('User level: ' . $userdata->user_level . "\n"); echo('User ID: ' . $userdata->ID . "\n"); ?> <div style="border:1px solid blue; width:50%; padding:10px">Username: Zedd<br /> 用户级别: 10<br /> 用户ID: 1</div> === Using Separate Globals === === 使用分开的 Globals === Much of the user data is placed in separate global variables, which can be accessed directly. 大多数用户的数据都放置在分开的全局变数中,你可以直接访问这些变数。 <?php global $display_name , $user_email; get_currentuserinfo(); echo($display_name . "'s email address is: " . $user_email); ?> <div style="border:1px solid blue; width:50%; padding:10px">Zedd's email address is: fake@email.com</div> <?php global $display_name , $user_email; get_currentuserinfo(); echo($display_name . "'s email address is: " . $user_email); ?> <div style="border:1px solid blue; width:50%; padding:10px">Zedd's email address is: fake@email.com</div> == Parameters == == 参数== This function does not accept any parameters. 这个函数不接受任何参数。 To determine if there is a user currently logged in, do this: 可以执行下面的步骤,决定当前有没有用户登录进来: <?php global $user_ID; get_currentuserinfo(); if ('' == $user_ID) { //no user logged in } ?> <?php global $user_ID; get_currentuserinfo(); if ('' == $user_ID) { //no user logged in } ?> Here is another IF STATEMENT Example. It was used in the sidebar, in reference to the "My Fav" plugin at http://www.kriesi.at/archives/wordpress-plugin-my-favorite-posts 下面是另一个IF STATEMENT的例子。这个例子是用在边框中,指的是http://www.kriesi.at/archives/wordpress-plugin-my-favorite-posts中的"My Fav"插件。 <pre> <?php if ( $user_ID ) { ?> <!-- enter info that logged in users will see --> <!-- in this case im running a bit of php to a plugin --> <?php mfp_display(); ?> <?php } else { ?> <!-- here is a paragraph that is shown to anyone not logged in --> <p>By <a href="<?php bloginfo('url'); ?>/wp-register.php">registering</a>, you can save your favorite posts for future reference.</p> <?php } ?> </pre> <pre> <?php if ( $user_ID ) { ?> <!—输入信息,登录的用户能够看到 --> <!-- in this case im running a bit of php to a plugin --> <?php mfp_display(); ?> <?php } else { ?> <!—下面有一个段落,显示给任何没有登录进来的人看 --> <p>By <a href="<?php bloginfo('url'); ?>/wp-register.php">registering</a>, 你可以保存你最喜欢的文章,供以后阅读。</p> <?php } ?> </pre>
摘要:
请注意,您对站长百科的所有贡献都可能被其他贡献者编辑,修改或删除。如果您不希望您的文字被任意修改和再散布,请不要提交。
您同时也要向我们保证您所提交的内容是您自己所作,或得自一个不受版权保护或相似自由的来源(参阅
Wordpress-mediawiki:版权
的细节)。
未经许可,请勿提交受版权保护的作品!
取消
编辑帮助
(在新窗口中打开)