Title: Welcome Message for users
Last modified: October 3, 2016

---

# Welcome Message for users

 *  Resolved [jnhaswell](https://wordpress.org/support/users/jnhaswell/)
 * (@jnhaswell)
 * [9 years, 7 months ago](https://wordpress.org/support/topic/welcome-message-for-users/)
 * Hi Everyone!
 * I’m trying to create a simple welcome message that displays in the header when
   a user logs in. Something like Welcome (user)!
 * I tried to use the following code, but I’m getting a syntax error:
 * function displayName () {
    global $user_identity; get_currentuserinfo(); echo“
   Welcome Back” . $user_identity;
 * Any thoughts on what I might be doing wrong to accomplish this?
 * Thanks
    John

Viewing 1 replies (of 1 total)

 *  Plugin Author [Shea Bunge](https://wordpress.org/support/users/bungeshea/)
 * (@bungeshea)
 * [9 years, 7 months ago](https://wordpress.org/support/topic/welcome-message-for-users/#post-8254799)
 * It might help if you posted the specific error, but first of all I notice that
   you’re missing the closing function brace – I’m not sure if this was just a copy
   error, but you’ll want to fix this if it exists in the actual code:
 *     ```
       function displayName () {
       	global $user_identity;
       	get_currentuserinfo();
       	echo "Welcome Back" . $user_identity;
       }
       ```
   
 * Secondly, you might want to reconsider your use of the `get_currentuserinfo()`
   function, which is currently deprecated. Instead, use the `wp_get_current_user()`
   function.
 *     ```
       function displayName ()
       	$user = wp_get_current_user();
       	echo "Welcome Back" . $user->display_name;
       }
       ```
   
 * Thirdly, as this plugin simply executes snippets, you’ll need to make sure that
   you are actually calling your function to have it do something. You can achieve
   this by creating a shortcode which you then later use in a post or page, or hooking
   it to a theme-specific hook, if the theme you use supports them:
 *     ```
       function wporg_welcome_message()
       	$user = wp_get_current_user();
       	echo "Welcome Back" . $user->display_name;
       }
   
       // use the [welcome_message] shortcode in a post or page
       add_shortcode( 'welcome_message', 'wporg_welcome_message' );
   
       // this won't work unless you change the action hook to something supported by your theme
       add_action( 'theme_below_header', 'wporg_welcome_message' );
       ```
   

Viewing 1 replies (of 1 total)

The topic ‘Welcome Message for users’ is closed to new replies.

 * ![](https://ps.w.org/code-snippets/assets/icon.svg?rev=2148878)
 * [Code Snippets](https://wordpress.org/plugins/code-snippets/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/code-snippets/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/code-snippets/)
 * [Active Topics](https://wordpress.org/support/plugin/code-snippets/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/code-snippets/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/code-snippets/reviews/)

## Tags

 * [code](https://wordpress.org/support/topic-tag/code/)
 * [snippet](https://wordpress.org/support/topic-tag/snippet/)
 * [User Login](https://wordpress.org/support/topic-tag/user-login/)
 * [welcome message](https://wordpress.org/support/topic-tag/welcome-message/)

 * 1 reply
 * 2 participants
 * Last reply from: [Shea Bunge](https://wordpress.org/support/users/bungeshea/)
 * Last activity: [9 years, 7 months ago](https://wordpress.org/support/topic/welcome-message-for-users/#post-8254799)
 * Status: resolved