WordPress
wp_get_current_user ()
Zoeken…
Syntaxis
- wp_get_current_user ()
De huidige gebruiker ophalen
Het verkrijgen van alle informatie van de huidige gebruiker in wordpress met behulp van de vooraf gedefinieerde functie 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;
?>
Gebruik foreach loop om gebruikersinformatie te krijgen van 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
Licentie onder CC BY-SA 3.0
Niet aangesloten bij Stack Overflow