WordPress
wp_get_current_user ()
Buscar..
Sintaxis
- wp_get_current_user ()
Obteniendo el usuario actual
Obtención de toda la información del usuario actual en wordpress usando la función predefinida wp_get_current_user();
<?php
$current_user = wp_get_current_user();
echo "Username :".$current_user->user_login;
echo "Username :".$current_user->ID;
echo "Username :".$current_user->user_pass;
echo "Username :".$current_user->user_nicename;
echo "Username :".$current_user->user_email;
echo "Username :".$current_user->user_url;
echo "Username :".$current_user->user_registered;
echo "Username :".$current_user->user_activation_key;
echo "Username :".$current_user->user_status;
echo "Username :".$current_user->display_name;
?>
Utilice el bucle foreach para obtener información de usuario de wp_get_current_user ()
$user = wp_get_current_user();
foreach($user->data as $key=>$user_data){
if($key == 'user_pass' || $key == 'user_activation_key' || $key=='user_status'){}
else{
$nice_key = ucfirst(str_replace('_', ' ', $key));
if($key == 'user_registered'){
$user_data = date_i18n(get_option('date_format'), strtotime($user_data));
}
echo $nice_key . ' : ' . $user_data . '<br />';
}
}
Modified text is an extract of the original Stack Overflow Documentation
Licenciado bajo CC BY-SA 3.0
No afiliado a Stack Overflow