Site logo

Archived topic

Welcome mesage to logged in user

7 replies · Started by Rafael on October 16, 2022

Viewing posts 1–8 of 8

Hello:

Is possible to show in a custom link menu a wellcome message to logged in users?

It would be something like this: Wellcome (User name)......

Apreciate your help.

Rafael

Hi Rafael,

Is possible to show in a custom link menu a wellcome message to logged in users?

It's possible to print out a welcome message, but I'm not sure what you mean by showing in a custom link menu.

Can you explain a bit more?

I refer to this:

https://ibb.co/Q8H1Q7T

In a menu custom link I can decide where to show the user name and the wellcome message.

RAFael

I see.

We can create a shortcode to show the user name and activate the shortcode feature in menu using this PHP snippet:

add_shortcode( 'logged_in_user_name', function() {
    ob_start();

$current_user = wp_get_current_user();
printf( __( '%s', 'textdomain' ), esc_html( $current_user->display_name ) ) . '<br />';

    return ob_get_clean();
} );
add_filter('wp_nav_menu_items', 'do_shortcode');

Then add [logged_in_user_name] shortcode to your menu item:
https://www.screencast.com/t/a3HXmZ9NR8Eo

Excellent, it works!....

And how can I bold the user name??

Done..Thanks a lot....it works fine...............

You're welcome Rafael!

This archived topic is closed to new replies.