Archived topic
Welcome mesage to logged in user
7 replies · Started by Rafael on October 16, 2022
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:
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??
Hi Rafael,
That's odd. It should already be bold with the <b> tag. Can you provide the link to the site in question and share temporary credentials so we can check?
Please use the Private Information field for this: https://docs.generatepress.com/article/using-the-premium-support-forum/#private-information
Done..Thanks a lot....it works fine...............
You're welcome Rafael!