How do I call wp_get_current_user() in a plugin when plugins are loaded before pluggable.php?
The current result is "PHP Fatal error: Call to undefined function wp_get_current_user()" which makes sense, but doesn't help.
I need to use $current_user.
Here is the code I'm currently using:
$wp-init();
do_action( 'init' ); // Check site status
$file='http://xxxxxxxx.com/wp-admin/wp_includes/pluggable.php';
if ( is_multisite() ) {
if ( true !== ( $file = ms_site_check() ) ) {
require( $file );
die();
}
unset($file);
}
// Get the current user's info
$current_user = wp_get_current_user();
if ( !($current_user instanceof WP_User) )
return;
echo $current_user-user_login;
function paf_uname(){
return $current_user-user_login;
}