Get logged in user info in WordPress
Use wp_get_current_user() function to get logged in user info. We can use wp_get_current_user() function without any argument. It will return an object, if user is logged in else return 0. We can check if user is logged in using function is_user_logged_in(). I'm using the following code to get logged in user.
<?php
if ( is_user_logged_in() ) {
$getLoggedInUser = wp_get_current_user();
echo '<pre>';
print_r($getLoggedInUser);
}
?>
Also Read: Get custom post types in WordPress
Also Read: How to get all UK addresses by postal code
Use wp_get_current_user() function to get logged in user info. We can use wp_get_current_user() function without any argument. It will return an object, if user is logged in else return 0. We can check if user is logged in using function is_user_logged_in(). I'm using the following code to get logged in user.
<?php
if ( is_user_logged_in() ) {
$getLoggedInUser = wp_get_current_user();
echo '<pre>';
print_r($getLoggedInUser);
}
?>
Also Read: Get custom post types in WordPress
Also Read: How to get all UK addresses by postal code
Recommanded Articles
- Generate Dummy Posts in WordPress
- How to add captcha in Contact Form 7
- how to create a cron job in wordpress
- How to get form data in Contact Form 7
- Insert Update Delete Select query in WordPress
- How to increase website speed
- Create plugin in WordPress in which create table in DB on activate
- Create new tab under my account WooCommerce frontend
- Custom image sizes in WordPress
- Get posts by meta key and meta value in WordPress
Latest Comments
Cordial
08 Oct 2022Admin
08 Oct 2022