1

I'm reposting this question because the problem wasn't solved. In a relevant question the answer below may be the solution.

Apparently this is happening because the file /wp-includes/pluggable which contains the function doesn't get loaded until after the plugins are loaded. Indeed it is. So wrap whichever thing you're doing in a function, and hook it onto the plugins_loaded or init hook. (see the wp-settings.php file)

Where exactly do I write the add_action('plugins_loaded','my_function'); command? In the "wp-settings file", the "pluggable" or my own php file? All I want to do is to display the user info in a php file which is loaded in a page in wordpress,but I'm constantly getting the same error "call to undefined function". I've tried including the relevant php file, still doesn't work.

 <?php 
 global $current_user;
 get_currentuserinfo();
 echo $current_user->user_login;
 ?>
4

1 に答える 1

1

これはあなたのために働くかもしれません!!

require (ABSPATH . WPINC . '/pluggable.php');
global $current_user;
get_currentuserinfo();
echo $current_user->user_login;

プラグインに pluggable.php ファイルを含めるだけです。

于 2014-01-30T08:43:35.570 に答える