1

I have this code here

{exp:channel:entries
        author_id="1|CURRENT_USER"
        channel="foo"
        disable="categories|category_fields|member_data|pagination"
        dynamic="no"
        orderby="entry_id"
        sort="asc"
        parse="inward"
}
    ...
{/exp:channel:entries}

This code is supposed to return all the foo entries which as authored by

  • the admin (author_id=1)
  • the current logged in user (author_id=45)

The problem that I am having is that it doesn't get the correct entries.

I tried 2 variations as listed below but they didn't work.

author_id="1|{member_id}"
author_id="1|{logged_in_member_id}"

However, when hardcoding the values

author_id="1|45"

It returned the correct entries.

How do I solve this problem since I can't use hardcoded values in the code?

1

it should be work , but it doesn't I think it is a bug.

anyway u can work around this problem with exp:member:custom_profile_data

{exp:member:custom_profile_data}   
{exp:channel:entries
        author_id="1|{member_id}"
        channel="foo"
        disable="categories|category_fields|member_data|pagination"
        dynamic="no"
        orderby="entry_id"
        sort="asc"
        parse="inward"
}     

.....

{/exp:channel:entries}
{/exp:member:custom_profile_data}

Currently CURRENT_USER can use as alone value in channel loop but if u want to use CURRENT_USER in the channel loop instead off custom_profile_data , u can hack the EE code.

go to system/expressionengine/modules/channel/mod.channel.php Line 1845

$sql .= ee()->functions->sql_andor_string($author_id, 'm.member_id');

To

$author_id = str_replace('CURRENT_USER',ee()->session->userdata('member_id'),$author_id);
$sql .= ee()->functions->sql_andor_string($author_id, 'm.member_id');

Note: And you can aloes use embed templates to solve problem like this.

Regard's.

| improve this answer | |
  • I think the code above using {exp:member:custom_profile_data} only applies for ExpressioneEngine 1.x – developarvin Mar 13 '14 at 23:37
  • this code is work fine and I check it on EE2.8.0 – Ahmad Saad Mar 14 '14 at 0:07
  • Ok it seems to work when I used {member_id} instead of {logged_in_member_id} – developarvin Mar 14 '14 at 4:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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