WordPress get current user data from new php page

I have a new php page and I’m using wordpress for my website.

From within my new php file I’ve included wp_load..

Read More
include ('wp-load.php');

which I believe is required in order to retrieve current user details.

I’ve then tried to echo the current loginname:

$current_user->user_login

but it’s coming out empty and I know it’s not..

UPDATE:

This is what I’m trying…

include ('wp-load.php');
global $current_user;
$current_user = wp_get_current_user();
$myuserlogin = $current_user->user_login;

echo $myuserlogin;

This is not returning anything…

I’m I missing anything?

RESULT:

This is the var_dump result:

[object Object]1object(WP_User)#79 (10) {
[“data”]=>
NULL
[“ID”]=>
int(0)
[“id”]=>
int(0)
[“caps”]=>
array(0) {
}
[“cap_key”]=>
NULL
[“roles”]=>
array(0) {
}
[“allcaps”]=>
array(0) {
}
[“first_name”]=>
string(0) “”
[“last_name”]=>
string(0) “”
[“filter”]=>
NULL
}

Related posts

Leave a Reply

1 comment