WordPress
wp_get_current_user ()
Sök…
Syntax
- wp_get_current_user ()
Få den aktuella användaren
Få all information om aktuell användare i wordpress med den fördefinierade funktionen 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;
?>
Använd förhandsslinga för att få användarinformation från 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
Licensierat under CC BY-SA 3.0
Inte anslutet till Stack Overflow