-
Hello,
Is there a simple way to change the default “Display Name Publicly As” for every user, including those that register in the future?
I’m using the snippet you provided here, but that displays the customer’s username. I want to display the first and last name.
Thanks!
-
Hi there,
Try this instead:
function db_display_current_user() { ob_start(); $current_user = wp_get_current_user(); if ( is_user_logged_in() ) { // Retrieve and display the user's first name and last name $first_name = $current_user->user_firstname; $last_name = $current_user->user_lastname; echo '<span class="current-user">' . $first_name . ' ' . $last_name . '</span>'; } else { echo '<span class="current-user">Message for not logged in user</span>'; } return ob_get_clean(); } add_shortcode( 'current_user_name', 'db_display_current_user' );
-
That worked, thanks!
-
No Problem 🙂
Viewing 4 posts - 1 through 4 (of 4 total)
- You must be logged in to reply to this topic.