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.

CURRENT_USER brings mixed results

April 28, 2011 11:47pm

Subscribe [1]
  • #1 / Apr 28, 2011 11:47pm

    TheBronzePatriot

    25 posts

    This question may be related to a resolved thread. (EE1 though)

    I am onto working on a client area for my site.  I have created a login page and simply just used the code from the user guide as my template.  I changed the return value to “clients/index”.  Where my issue lies is in the non-capability of listing all of the entries that a user is the author of after they log in.  I am using this code:

    {exp:channel:entries channel="clients" author_id="CURRENT_USER" dynamic="no" status="open"}
    {if no_results}There are no entries tied to this account{/if}
        {title}
    {/exp:channel:entries}

    I just want to test it out by listing just the titles before I get into custom fields and what not.  As far as users in the system, I have two dummy accounts and one entry that has a dummy account as the author and the other account doesn’t have any entries set as author.  What seems to be occurring is that I will login, under either account, and it will show the no_results line for both of them or if I remove the no_results tag it displays the lone entry on both accounts.  Making it appear then that the CURRENT_USER isn’t working correctly since only one account is the author of the lone entry and not both of them.

    I am using EE 2.1.3, Build 20110411.

    p.s - I double posted this as it is related to EE2 and not the resolved thread of EE1.  Sorry.  If a moderator wants to delete the old thread, that’d be great.

  • #2 / Apr 29, 2011 6:30pm

    Sue Crocker

    26054 posts

    Hi, TBP.

    Not to worry, I closed your earlier thread.

    As far as CURRENT_USER goes, I’d double check that you really are logged in.

    rl
    {if logged_in}
    You're logged in!
    {if:else}
    You aren't logged in!

    What I suspect is that your other page is either using the www or non-www version of the site..

    Might that be the issue?

    If that is the case, you’ll need to set the cookie domain.

    EEDocs:// Cookie Settings

  • #3 / May 01, 2011 6:44pm

    TheBronzePatriot

    25 posts

    I ended up switching it to:

    ....user_author_id="CURRENT_USER" dynamic="no"...

    and that seemed to fix it.  I did also test whether or not I was logged in or not while using the alternative syntax when logged in.  Seems to work now with this set up however in the back of my mind it doesn’t make sense.

  • #4 / May 02, 2011 4:59pm

    Sue Crocker

    26054 posts

    Hi, TBP. Glad that fixed whatever problem was going on.. Feel free to start a new thread if you have any more questions.

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

ExpressionEngine News!

#eecms, #events, #releases