ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Member Login Redirect based on Member Group

September 21, 2010 2:21pm

Subscribe [4]
  • #1 / Sep 21, 2010 2:21pm

    digital1

    25 posts

    Hi, I am trying to setup member:login to redirect the user to a different template based on their assigned Member Group. Here is what I have so far:

    {exp:member:login_form
          {if member_group == "10"} return="template/one" 
          {if:elseif member_group == "11"}  return="template/two" 
          {if:else}  return="template/three" {/if}  
    }

    However, it always reverts to the last if:else statement and returns to template/three (or whatever I put in there). It apparently is not reading the member_group variable.

    Is this proper syntax? Is there a better way of coding this? Ideas?

    Using EE2.1.0 and Solspace User.

    Any help would be appreciated! Thank you!

    Jeff

  • #2 / Sep 21, 2010 3:18pm

    kellypacker

    138 posts

    I think this has something to do with the parse order. Simple conditionals are parsed before module tags, but advanced conditionals are parsed after.

    Does this work?

    {exp:member:login_form
          {if member_group == "10"} return="template/one"{/if}
          {if member_group == "11"}  return="template/two"{/if}
          {if member_group != "10"}{if member_group != "11"}  return="template/three" {/if}  
    }

    Actually I think, {member_group} parses at the end, so it might not. Try it out.

  • #3 / Sep 21, 2010 4:43pm

    digital1

    25 posts

    Hi Kelly, thanks so much for your reply. That does not appear to work either. Same result of going to template/three. I even tried:

    {exp:member:login_form
          {if logged_in_group_id == "10"} return="template/one"{/if}
          {if logged_in_group_id == "11"}  return="template/two"{/if}
          {if logged_in_group_id != "10"}{if logged_in_group_id != "11"}  return="template/three" {/if}  
    }

    with the same result of reverting to template/three.

    Thoughts?

  • #4 / Sep 21, 2010 11:15pm

    kellypacker

    138 posts

    Because the {member_group} parses last, the only thing I can think of is embed the form is a subtemplate and pass it the {member_group} variable.

    Seems kind of hacky, but I can’t think of a better solution.

  • #5 / Sep 24, 2010 12:56pm

    digital1

    25 posts

    Grrr, there has to be a way. I am wondering if I can have a dropdown within the member:login that allows the user to choose what group they are in?

  • #6 / Sep 24, 2010 1:53pm

    kellypacker

    138 posts

    Did you try to pass the {member_group} to a subtemplate?

  • #7 / Sep 24, 2010 1:59pm

    kellypacker

    138 posts

    oh probably not because it’s a login form and they are not part of any member group yet. You can make a member_group drop down if you want them to choose. I’ve done that.

    Or you could do conditionals on the return template. Embed a subtemplate for every member group and pass the {member_group} variable to the subtemplate.

  • #8 / Sep 24, 2010 2:51pm

    Rob Sanchez

    335 posts

    Create a “routing” template:

    login template:

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

    login/redirect template

    {if logged_in_member_group == "10"}{redirect="template/one"}{/if}
          {if logged_in_member_group == "11"}{redirect="template/two"}{/if}
          {if logged_in_member_group != "10" && logged_in_member_group != "11"}{redirect="template/three"}{/if}
  • #9 / Sep 24, 2010 4:59pm

    digital1

    25 posts

    Thanks Kelly and Rob, I’ll give those a shot this weekend and let you know how it turns out. Just trying to keep my head wrapped around it.

    Thanks again!

  • #10 / Sep 28, 2010 4:26pm

    digital1

    25 posts

    The redirect sub-template worked perfectly. Thanks so much!

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases