我尝试用WordPress创建登录和注销页面。我想我需要使用currentuserinfo()
来退出,但这对我来说太难了。当我测试它时,我可以看到。
我的PHP代码如下:
require_once("../soft/wp-config.php");
require_once("../soft/wp-load.php");
global $user_ID, $user_identity; get_currentuserinfo(); if (!$user_ID) {
if ( is_user_logged_in() )
echo("wp login");
else{
echo("wp logout");
}
$current_user = wp_get_current_user();
if ( 0 == $current_user->ID ) {
echo("wp logout");
} else {
echo("wp login");
}
global $current_user;
get_currentuserinfo();
echo 'Username: ' . $current_user->user_login . "\n";
echo 'User email: ' . $current_user->user_email . "\n";
echo 'User level: ' . $current_user->user_level . "\n";
echo 'User first name: ' . $current_user->user_firstname . "\n";
echo 'User last name: ' . $current_user->user_lastname . "\n";
echo 'User display name: ' . $current_user->display_name . "\n";
echo 'User ID: ' . $current_user->ID . "\n"; ?>
结果: