我正在试图弄清楚当前用户是否可以管理选项。我正在使用以下代码:
if (current_user_can('manage_options')) {
add_filter('comments_array', 'myFunctionCall');
}
但是它产生了这个错误(在最新的WordPress 2.9.2中):
致命错误:调用未定义 函数wp_get_current_user()in /Users/******/Sites/*****.com/wp-includes/capabilities.php 969行
我是以错误的方式解决这个问题吗?
答案 0 :(得分:3)
我检查了你的代码并在我的网站上正常工作(也使用WP 2.9.2。)
检查pluggable.php
内的/wp-includes
文件中是否定义了该功能。
在我的WP安装中,我已经从第69行到第76行定义了函数:
if ( !function_exists('wp_get_current_user') ) :
/**
* Retrieve the current user object.
*
* @since 2.0.3
*
* @return WP_User Current user WP_User object
*/
function wp_get_current_user() {
global $current_user;
get_currentuserinfo();
return $current_user;
}
endif;