How to display user – display name,avatar and logout button in WordPress : Example
Beginner , PHP , Snippets , Wordpress / July 8, 2018

To display user displayname , avatar and provide a logout button for a user in your wordpress site,we can use the following  five worpress functions. is_user_logged_in () –  Check whether used in. wp_get_current_user(id/email,null)  –  Get current logged in user get_avatar_url(userid) – Get avatar url for current user using userid wp_logout_url(url) – Logout and redirect URL home_url() – Get your home URL  

  Check below links to see documentation in full https://developer.wordpress.org/reference/functions/is_user_logged_in/ https://developer.wordpress.org/reference/functions/wp_get_current_user/ https://developer.wordpress.org/reference/functions/get_user_by/ https://developer.wordpress.org/reference/functions/wp_logout_url/        

Share this page in social media platforms