We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Parsing order - if logged_in with solspace user module

Development and Programming

dj-rowan's avatar
dj-rowan
30 posts
16 years ago
dj-rowan's avatar dj-rowan

This question may be related to a resolved thread.

I have been starting to work with the Solspace Users module also- and I’m having a similar problem, but my question has to do with the order in which EE tags are parsed.

Basically, I want to check to see if a user is logged in- and show the registration form if they are not logged in.

{if logged_in}
    Debug: You are logged in!
{if:else}    
    Debug: You are logged out!
    {exp:user:register form_name="register" return="http://208.86.252.6/~bellyfit/index.php/training/courses/nanaimo-april-2009"}
     
    Username: <input type="text" name="username" class="input" size="25" /></p>
    Screen Name: <input type="text" name="screen_name" class="input" size="25" /></p>
    Email Address: <input type="text" name="email" class="input" size="40" /></p>
     
    Password: <input type="password" name="password" class="input" size="25" /></p>
    Confirm Password: <input type="password" name="password_confirm" class="input" size="25" /></p>
     
    Accept Terms?: <input type="checkbox" name="accept_terms" value="y"  /> Accept Terms?
     
    <input type="submit" value="Submit" /></p>
     
    {/exp:user:register}        
{/if}

If i remove the ‘exp:user:register’ tag pair, the error dissapears, but with the above code, I get the “You are already registered and logged in.” error.

Question: Is it possible that the parsing engine sees the Register tags before the {if logged_in} tags?

Please help!

thanks, Rowan

Moved to Modules forum by Moderator

       
Sue Crocker's avatar
Sue Crocker
26,054 posts
16 years ago
Sue Crocker's avatar Sue Crocker

Rowan, have you asked for help on the Solspace forums? Since this involves a third party module, I’m going to move it.

       
dj-rowan's avatar
dj-rowan
30 posts
16 years ago
dj-rowan's avatar dj-rowan

I have posted on their forums also. I thought this might be a general EE thing as it seems the tags within the {if} statments are being parsed before the ifs are.

Just trying to figure it out as rapidly as possible.

thanks for your help

rowan

       
Matt Weinberg's avatar
Matt Weinberg
489 posts
16 years ago
Matt Weinberg's avatar Matt Weinberg

Dj-rowan–look at the parse order (http://expressionengine.com/wiki/Parse_Order/), and you’ll see that advanced conditionals (which includes ones using if:else) are parsed pretty late. Essentially both “conditions” are parsed and then the one that “fails” the condition is hidden. Try using:

{if logged_in}
    Debug: You are logged in!
{/if}
{if logged_out}
Reg code...      
{/if}
       
dj-rowan's avatar
dj-rowan
30 posts
16 years ago
dj-rowan's avatar dj-rowan

Hi Slapshotw -

thanks for the hint- I think it has led me to find a very practical work-around.

Dj-rowan–look at the parse order (http://expressionengine.com/wiki/Parse_Order/), and you’ll see that advanced conditionals (which includes ones using if:else) are parsed pretty late. Essentially both “conditions” are parsed and then the one that “fails” the condition is hidden. Try using:

From reading elsewhere, I understand that template embeds are parsed very late too. So, what I’ve done is placed an embed in the {if logged_out} tag pair.

{if logged_in}
    Debug: You are logged in!
{/if}
{if logged_out}    
    Debug: You are logged out!
    {embed="crew/regForm"}        
{/if}

crew/regForm contains:

{exp:user:register form_name="register" return="http://208.86.252.6/~bellyfit/index.php/training/courses/nanaimo-april-2009"}
     
    Username: <input type="text" name="username" class="input" size="25" /></p>
    Screen Name: <input type="text" name="screen_name" class="input" size="25" /></p>
    Email Address: <input type="text" name="email" class="input" size="40" /></p>
     
    Password: <input type="password" name="password" class="input" size="25" /></p>
    Confirm Password: <input type="password" name="password_confirm" class="input" size="25" /></p>
     
    Accept Terms?: <input type="checkbox" name="accept_terms" value="y"  /> Accept Terms?
     
    <input type="submit" value="Submit" /></p>
     
    {/exp:user:register}

This is working so far for me. If I encounter any more problems with this, I will post again.

Thanks for the help!

rowan

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.