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

No_Results running when it shouldnt be

Development and Programming

Eric N's avatar
Eric N
27 posts
5 years ago
Eric N's avatar Eric N

I have a standard if/else statement that even when it is negative for the code to be run, a part of the code still runs.

This should only run the channel entries code IF the user is logged in, and belongs to the specific member group.

However, when logged out, it runs the “redirect” code below regardless. If I remove the redirect code it works fine, but I want that to work. Am I missing something or is this a bug?

Here it is

{if logged_out}
         Show log in form
     {if:elseif member_group != 5 }
         Show error message for not being part of member group
     {if:else}
         {exp:channel:entries channel="channel_name"  admin_id="CURRENT_USER" limit="1"}
              {if no_results}
                   {redirect="path/here"} <-- this runs if not logged in ????
              {/if}
          other code
      {/exp:channel:entries}
   {/if}
       
Robin Sowell's avatar
Robin Sowell
13,158 posts
5 years ago
Robin Sowell's avatar Robin Sowell

Try it with logged_in_group_id instead of member_group a la:

{if logged_out}
         Show log in form
     {if:elseif logged_in_group_id != 5 }
         Show error message for not being part of member group
     {if:else}
         {exp:channel:entries channel="channel_name"  admin_id="CURRENT_USER" limit="1"}
              {if no_results}
                   {redirect="path/here"} <-- this runs if not logged in ????
              {/if}
          other code
      {/exp:channel:entries}
   {/if}

That work?

       

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.