Show logged user name
-
Hi.
When my user is logged in. Can I display ‘Hello Username‘ somewhere? So the user knows he is logged in? Can I do something that the name is displayed? I tried with the shortcode [user-data field_name=’First Name’] but its not showing…Thank you
-
Hi Anoukgo,
We tried this [user-data field_name=’First Name’] shortcode on our side and it is displaying first name of the Logged in user. Can you create a test page and use this shortcode in that page and try. That way we can make sure there is no other thing that is conflicting to that shortcode. When you are writing this shortcode please make sure your writing in text mode instead of visual mode. That way wordpress don’t render ‘[]’ in html entity. Also, just to make sure do you have a field that is called exactly “First Name”?
Thank you
Yes I tried the shortcode, the name of the field is correct. Also I am writing in text mode. Still not showing. I tried with widget and that is working. But i need this inside my text, therefore I cant use the widget..
Another question.
Is it possible to put a line in a page template that would show ‘Welcome User! Logout’ on top of EVERY page once the user is logged in.
But when user is not logged in, that line would not exist?
Is this possible?Thank you
I figured out the shortcode thing, its working now, apparently i had to restart the computer..
I have other problem.
How could i make the whole page not visible until you are logged in.
Because I am using widgets on a page and I cant use the shortcode [registered] for widgets..
Meaning.
I have a page where you log in. Here I can use or shortcode for login or the login/logout widget. Both works. This is ok. This redirects you to another page that shouldnt be visible to non-logged in users. Here I want the ‘Welcome User’ and Logout option on top of the page.
Now what I did. I used a widget to show the ‘Welcome User’ And put the login/logout widget next to it that at the moment you are on this page shows ‘logout’ (you are already logged in because login redirects you to this page). I am not the most happy about this option but I can live with it. I would rather have it on top of the page, not inside my content area..
The problem is when I want to open any other pages. While I am logged in I can stil go to any other page and I want that ‘Welcome User’ to show on every page.
For that I should change my page template php file?Hi anoukgo,
If you want to display page content only when user is logged in. You can use [restricted] shortcode. You can add your content in this shortcode. For example [restricted] your privet content [/restricted].
If you want functionality to restrict menu for on logged in user. You can try to make use of our available public functions, which allow you to check if a visitor is logged in and display stuff conditionally based on that. We created a tutorial video that explains this and even includes an example of setting up a conditional menu, which you can watch here:
Thank you
thank you for your answer.
I understand the [restricted] method and it could work if i only want to hide some content on the page. With this shortcode I can’t restrict the widgets and other things on my page. That is why I want to restrict my whole page (only one or two on my whole site)..
This method to create conditional menu and show different menu for logout and login user sounds great. But I an kinda new to this and have a question. In which file, where could I add this function? in header.php?
Thank you!
Hi anoukgo,
You would normally place it in the theme file that generates/controls the content you want to restrict. For example, a lot of themes have widgets in the sidebar.php file.
The topic ‘Show logged user name’ is closed to new replies.