From the course: WordPress Development: Coding Practice
Unlock the full course today
Join today to access over 24,400 courses taught by industry experts.
When a user logs in, greet them by their name - WordPress Tutorial
From the course: WordPress Development: Coding Practice
When a user logs in, greet them by their name
- [Instructor] There's nothing like personalization. So let's make it so that when a user logs in, we greet them by their first name or if their first name doesn't exist, their username. We're going to need to redirect the user to a page in order to do this. So there are actually two functions, one for the redirect and one to display the user's name. Here are the requirements. Check to see if a user logs in. Redirect them to a page in your WordPress site that has the greeting via shortcode. Greet them by their display name. If there is no display name or no one is logged in, fall back to a generic greeting. I'm using hello there. This will be slightly different from using the wp_login action, so keep that in mind. With that, let's look at our starter code. So we have a couple of functions here you're going to need to fill in. One is the login_redirect. As a note, I will be redirecting them to a page that has the slug…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
Dynamic copyright year2m 50s
-
(Locked)
Randomize posts5m 37s
-
(Locked)
Get post meta3m 19s
-
(Locked)
Change admin colors based on the server5m 18s
-
(Locked)
Create your own block pattern5m 58s
-
(Locked)
Append a message to RSS content5m 31s
-
(Locked)
Sanitize input4m 39s
-
(Locked)
Sanitize output4m 4s
-
Add a sitewide banner to the top of the page3m 32s
-
(Locked)
Register a custom post type5m 37s
-
(Locked)
Store user meta5m 29s
-
(Locked)
Send an email to the admin when a plugin is activated6m 42s
-
(Locked)
When a user logs in, greet them by their name4m 44s
-
(Locked)
Create a transient5m 30s
-
(Locked)
Hide content based on a query string5m 49s
-
-