获取Wordpress用户信息[关闭]

Good night guys, I am not very familiar with Wordpress, but I am already completing my task, I can already send email, capture choice via jquery with Ajax processing email sending, but I can not capture the user logged in to Wordpress, I need a light. Thankful, Siro Souza

<html>
<body>
<meta http-equiv="refresh" content="2; url=index.php">
<?php
$location = $_SERVER['DOCUMENT_ROOT'];
include ($location . '/wp-config.php');
include ($location . '/wp-load.php');
include ($location . '/wp-includes/pluggable.php');
global $current_user;
\etorna os dados do usuário logado
$current_user = wp_get_current_user();
\\ passamos o ID do usuário e geramos o array
$user_info = get_userdata($current_user->ID);
$first_name = $user_info->first_name;
$user_email = $user_info->user_email;
if(is_user_logged_in()){
$premium = $_POST['chosen_premium'];
$vnome = $first_name; 
$vemail_origem = $user_email;
$vassunto = "Prêmio Escolhido"; 
$vmensagem = $premium;
$msg="Nome: $vnome
"; 
$msg.="Email: $vemail_origem
"; 
$msg.="Assunto: $vassunto
"; 
$msg.="Mensagem: $vmensagem
";

If you are inside your plugin or theme files you should be able to use somewhat similar code to the above...

if (is_user_logged_in()) {
    $current_user = wp_get_current_user();
    $user_info = get_userdata($current_user->ID);
    echo '<pre>user_info: ' . print_r($user_info, true) . '</pre>';//debug
}

Are you trying to run this from outside of WordPress? If you are still having issues, perhaps can you provide more details on what file you are using for your code?