Jump to content

Magic menu logic to link based on logged in

Closed 1.1.2

Wondering how to use the magic menus to link to a URL based on whether the user is logged in. In a magic menu, I have:

      {{$member=\IPS\Member::loggedIn();}}

 {{if ($id>0)}}

LINK1

{{else}}

LINK2

{{endif}}

How do I send a redirect to the correct page/link within the template logic? Or do I use a Magic Menu at all? Is there a different way to do this?

 

Thanks!

Share this comment


Link to comment

you are on the right track, you just need to write the html yourself for it:

{{if \IPS\Member::loggedIn()->member_id}}
<a href="foo.html">Logged In</a>
{{else}}
<a href="foo2.html">Logged Out</a>
{{endif}}

Screenshot 2020-12-01 094057.png

Share this comment


Link to comment

Thanks @Michael

I should have been more clear, however. Instead of displaying the link based on logic, I just want to send them there onclick.

I'm looking how to write the code so that when the user clicks on the actual menu, they are directed to a particular link.

So if they are logged in, the JOIN menu item click sends them to PAGE01 and if not logged in, a menu clicks sends them to PAGE02

Thanks

 

Share this comment


Link to comment

well then the magic menu isn't what you want. the magic menu will create a sub menu so you can create a customize sub menu outside of what mgm offers.

you can create two menu items instead, and set one to have permissions only for guest and the other one for actual groups.

Screenshot_1.png

Share this comment


Link to comment
×
×
  • Create New...