1

I'm trying to use if logged_id & auther_id="CURRENT_USER" to load a specific entry back to users. However I'm seeing mixed results. I'm using EE 2.5.2 and Safecracker and have had success with this, however I have also had have had about 1/2 of the people who have resubmitted end up with new entries vs. updating the entry already stored. The first line of code is what I'm using to check to see if a user has already submitted a entry.

{if logged_id}<a href="/template-group/template/{exp:channel:entries channel="my_channel_name" author_id="CURRENT_USER" status="open" dynamic="no"}{username}/{/exp:channel:entries}">

This line of code is the start of the template, which should display the past entry if a user has submitted one.

{if logged_in}
{exp:safecracker channel="my_channel_name" id="my_channel_name" return="/" url_title="{segment_3}" author_only="yes"}

Any help in figuring out what is causing this would be greatly appreciated, Thank you!

6
  • Not sure if this is representative of your actual code, but you have {if loggged_id} in the first conditional. What happens if you change to match the second conditional of {if logged_in}? Commented Dec 6, 2013 at 14:26
  • Sorry that was just a typo in my post, the actual code is {if logged_in}
    – philecker
    Commented Dec 6, 2013 at 14:28
  • Have you looked at the EE change log? You're using a pretty old version of EE - could this be a bug fixed in a newer version? Commented Dec 6, 2013 at 15:22
  • @BrianLitzinger I haven't, I look but not sure if that helps as I've tried to update a couple times from 2.5.2 to 2.7.2 without any success. The site i'm working on is using quiet a few add-ons and I think may be causing an issue with the ugprade process.
    – philecker
    Commented Dec 6, 2013 at 15:46
  • I checked that setting and I do not have that enabled, thoughts?
    – philecker
    Commented Dec 6, 2013 at 15:49

1 Answer 1

2

The {if logged_in} is checked last in the template (advanced conditional). There are several addons available that create early parsed global variables from user data. Use the template debugger to verify if tags and modules are or are not called at all.

{if logged_in_member_id} ... {/if} // mo-variables, low-vars($)
{if global_member_id} ... {/if}    // global_member_vars

The first part can be a channel:entries tag by itself, current_user will be 0 when not logged in, giving the no_results part back.

{exp:channel:entries channel="my_channel_name" 
    author_id="CURRENT_USER" status="open" dynamic="no"
}
    {if no_results} -- redirect or show other info -- {/if}
    <a href="{path=/group/template/{username}/"></a>
{/exp:channel:entries}
2
  • Thanks @GDmac does that make sense that sometimes with using CURRENT_USER everything is working correctly, but sometimes it not? Do you think by using Mo-Variables that would correct my issue?
    – philecker
    Commented Dec 9, 2013 at 18:18
  • author_id = CURRENT_USER should work as advertised [EE manual]. However your question is also about safecracker (which is now channel:form). I would avoid nesting channel:form inside channel:entries (variables like title, entry_id might collide), for channel:form you can use require_entry=yes, url_title=segment_x and (important) author_only=yes. [channel:form manual].
    – GDmac
    Commented Dec 12, 2013 at 8:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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