• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
Baguiowebs

Baguiowebs

Learn WordPress. Build Your Own Site.

  • Contact
  • Build a Site
  • WP Training
  • Library
  • Signup
  • Login
  • Contact
  • Build a Site
  • WP Training
  • Library
  • Signup
  • Login

Personal Greeting Shortcode

Hi, Login
X

Join Us Forgot Password?

to view this video. Not a member? Join Now!

Below is the copy-and-paste code snippet as mentioned in the above video:

/*
 This shortcode [get-user-first-name] will display the logged in Users first name only. 
 */
add_shortcode('get-user-first-name','get_user_first_name');
function get_user_first_name()
{
	$current_user 	= wp_get_current_user();
	$first_name 	= $current_user->user_firstname;
	$last_name 	= $current_user->user_lastname ;
	return $first_name;
}

/*
 This shortcode [greet_user] will display the word Welcome followed by the logged in Users first name. 
 */

add_shortcode('greet_user','greet_user');
function greet_user()
{
	$current_user 	= wp_get_current_user();
	$first_name 	= $current_user->user_firstname;
	$last_name 	= $current_user->user_lastname ;
	return "Welcome, $first_name";
}

Filed Under: WP Theme Customization

Primary Sidebar

Section 6

WP Theme Customization

Introduction

  • Before We Customize3:49min
  • How To Create A Child Theme4:49min

Shorcodes

  • Personal Greeting Shortcode3:22min
  • Flex Date Shortcode5:45min

Theme Customization Tuts

  • Remove URL Underline4:54min
  • Remove Incorrect Login Shake1:39min
  • Rebrand Admin Bar WP Logo2:46min
  • Remove Top White Space1:33min
  • Adjust Gap Between Posts on Homepage1:55min
  • Add Border Below Header2:19min
  • Customize Site Description2:16min
  • Customize Site Title2:17min
  • Random Admin Announcement4:47min
  • Add Drop-Down Menu To Admin Bar3:59min

Copyright © 2022 Baguiowebs. All Rights Reserved.

  • About
  • Disclaimer
  • Privacy Policy
  • Terms