-
- 1 Posts
Hello,
I have worked myself, but i have some problems
Small Question: I have installed on "System", "Package Management" Login. How to login now called:
1) Package
2) Module
3) Extra
4) Plugin
What is the correct name?
My question is: if I have made an Login via the login dialog (newly registered users group "Webdesigners") appears, a logout link, so I know that the system recognizes the logged in user.
How can I now change the menu or identify with PHP snippets, placeholders etc, whether the user is logged in and what group he belongs to.
The code:
[[+ modx.user.id: memberof = `web designers`: then = `Hello` web designers: else = `Hello visitor`]]
it works but is not enough.
Thanks for help and sorry for my english.
-
- 24,544 Posts
The Personalize snippet will show one chunk to logged-in users and another chunk to not-logged-in users, so it's just a matter of putting different content in the different chunks.
If you need to personalize the output based on user groups, you can use the &allowedGroups property in the Personalize snippet tag.
The contents of the chunk you show to a particular group can be an entire menu (or a different Wayfinder call) or it can be as small as 'Hello web designers'.
For example:
YesChunk:
<p>Hello web designers</p>
NoChunk:
BTW, Login is a package (and also an extra) that includes several snippets. The Login Snippet is the one you use to let people log in.
Welcome to MODX
Personalize tag:
[[!Personalize?
&allowedGroups=`web designers`
&yesChunk=`YesChunk`
&noChunk=`NoChunk`
]]
[ed. note: BobRay last edited this post 10 years, 7 months ago.]
Of course, this being MODx, there are other ways of doing much the same thing. For example, you can use the "user" output modifiers to get most of the information you might want to display, such as Full Name:
[[!+modx.user.id:userinfo=`fullname`]]
Use them to determine if the user is a member of a specified group (no programming needed)
[[!+modx.user.id:memberof=`Administrator`:then=`Administrator`]]
[[!+modx.user.id:memberof=`Guests`:then=`Guest`]]
[[!+modx.user.id:memberof=`web designers`:then=`Web Designer`]]
Or use a snippet to determine the user's group:
$groups = $modx->user->getUserGroups();
will return an array of the user groups the user is assigned to that you can work with.
If you are using Wayfinder, it won't make a menu entry for resources the user does not have permission to view.