wp_get_current_user() fails
-
Hi, I can’t get the current user who’s logged in to wp using wp_get_current_user() on WP 3.2.1.
https://codex.www.ads-software.com/Function_Reference/wp_get_current_userOn both my working site (on the internet) and on production site (LAN), it fails to return any value. On the working site which is rental server, no html is returned so that I have no way to know what’s going on.
Sample code in use:
<?php require_once ('../wp-includes/pluggable.php'); test_wp_get_current_user(); function test_wp_get_current_user(){ $current_user = wp_get_current_user(); echo 'ID= '. $current_user->ID; echo 'id= '. $current_user->id; echo 'last name= '. $current_user->last_name . '<br />'; echo 'user= '. $current_user . '<br />'; } ?>
Btw, although not sure if this is relevant, but on production site, I see from web server’s error.log that errors like this occurs (below is an example. undef func varied once I add require declaration as follows):
PHP Fatal error: Call to undefined function is_ssl() in /usr/share/wordpress/wp-includes/pluggable.php on line 672
Ended up adding these to pluggable.php in order to stop errors:
require_once 'capabilities.php'; require_once 'functions.php'; require_once 'load.php'; require_once 'plugin.php'; require_once 'user.php';
- The topic ‘wp_get_current_user() fails’ is closed to new replies.