2

I have a log-in page that needs to direct users to content based on their member group. Currently it is very simple with just two pages.

I have tried it using the single option and it directs correctly.

Example:

{exp:member:login_form return="member-area/" }

However, if I introduce a conditional into the mix, it does not redirect correctly:

{exp:member:login_form {if member_group == "5"} return="member-area/" {/if} {if member_group == "1" || member_group == "6" || member_group == "7" || member_group == "8"} return="internal-staff-center/" {/if} }

I suspect I have overlooked something. I would appreciate any assistance in getting this correctly.

Thanks.

Forrest

7
  • MediaGirl, Sorry but I am afraid you have overstepped your bounds closing out my question without providing any links to a solution. This is marked as an exact duplicate, however, I have not seen any other questions like it and this is the only one I posted. – forrest Jan 24 '13 at 19:49
  • I voted to reopen the question, but as look at it now it does look like the accepted answer in the thread you linked to in the start of your post includes an answer pretty much the same as Mark's solid answer below. See the part in the duplicate thread starting with "On the Login Form Tag set the return parameter..." So it does seem a duplicate, though maybe not an exact one! – Alex Kendrick Jan 24 '13 at 20:20
  • 1
    It seems like same answer, different question. The other question referred to starts with the premise of a custom control panel. This question's scope is limited handling users who log in anywhere in the site. – Mark J. Reeves Jan 24 '13 at 21:10
  • Yeah, the other question had a lot going on but the part labelled #2 seems pretty darn similar (redirect particular member groups in a unique way post-login). Still, I'm coming around to your way of thinking again. :) Maybe @Anna can take a look along with other moderators. It's up for debate just how similar a question needs to be to warrant closure! Leaving it open could potentially result in additional good answers. And because of its focus, this is a more findable post. – Alex Kendrick Jan 24 '13 at 21:32
  • 1
    I agree that although part of the other question contains similar elements, someone searching for one question may not find the other (especially since the other question asks specifically about login destination for the control panel). Have reopened. – Derek Hogue Jan 24 '13 at 22:03
4

What if you do:

{exp:member:login_form return="member-redirect/" }

And then in the member-redirect template you have your conditionals:

{if member_group == "5"} {redirect="member-area/"} {/if} {if member_group == "1" || member_group == "6" || member_group == "7" || member_group == "8"} {redirect="internal-staff-center/"} {/if}

You don't actually have access to your member_group variable when you set up the login form. You haven't logged the user in yet.

6
  • Hi Mark, I see the logic here, however, when I implement it, it gets stuck on the redirect page. I tried placing the redirect conditionals inside html code and alone by itself. Either way, it gets stuck. Any more suggestions on what I am still missing? – forrest Jan 24 '13 at 19:51
  • Hi Mark, I figured it out. You have the have the redirect code inside of { }, otherwise it won't work. Thanks. – forrest Jan 24 '13 at 19:56
  • Updated so it was clear that the redirects are tags. Please mark as answered? – Mark J. Reeves Jan 24 '13 at 19:58
  • 1
    Thanks. I wish mediaGirl hadn't closed this as exact duplicate because it is not exactly the same. – forrest Jan 24 '13 at 20:00
  • That other question is the same really as is the accepted answer. – Anna_MediaGirl Jan 24 '13 at 22:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.