Shortcode displayed instead of Username
-
I wanted to display my logged in User’s Username or Display Name in WP backend Dashboard.
So I entered the below Code:
function show_loggedin_function() { global $current_user; wp_get_current_user(); if ( is_user_logged_in() ) { echo $current_user->display_name; } else { echo '<a href="' . wp_login_url() . ' ">Login</a>'; } } add_shortcode( 'show_loggedin_as', 'show_loggedin_function' );
Unfortunately, when logged in, it still shows the shortcode instead of the Username, as can be seen here— https://prnt.sc/5xUmDzO_Wt7A
1.) Please, do you know how I can fix this?
Or, do you have a better code that can help me solve this issue?
Regards.
Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)
- The topic ‘Shortcode displayed instead of Username’ is closed to new replies.