I have a simple photo gallery where logged in users can upload photos. I've set the default status for all pictures to disabled, is it possible to show disabled pictures only to user who just published it, and when status is set to enabled everyone can see it?

  • How do you set the default status... with a custom field? Are the users uploading to an Assets field? – Brad Bell May 30 '16 at 23:21
  • All entries go to "featured users" channel, and status is set to disabled, not using a custom field but the built in system. Entries only have a title and 1 picture on custom asset field. – jarnof May 31 '16 at 7:33

There are a couple of aspects to consider in your question.

  1. Display entries to the author who created them
  2. Display entries which are disabled

I'll assume your Channel/Structure is named "Gallery Image"...

First, establish the User ID of the logged in User:

{% set loggedInUserID = currentUser.id %}

...then find Entries authored by the Logged in User:

{% set galleryEntries = craft.entries.section('galleryImage').authorId(loggedInUserID) %}

(Entry Author ID parameter info...)

... then loop through any entries which have a Status of "Disabled"

{% for entry in galleryEntries.status('disabled') %}
    <h2>Your draft Gallery entries</h2>

    ...(template code)...
{% endfor %}

(Entry Status parameter info...)

Another variation which you could use, which moves the Status parameter out of the For-Loop, is:

{% set galleryEntries = craft.entries.section('').authorID(loggedInUserID).status('disabled')%}
{% for entry in galleryEntries %}
    <h2>Your draft Gallery entries</h2>

    ...(template code)...
{% endfor %}
| improve this answer | |
  • 1
    Thanks a lot, from your example I managed to work it out. I set the entries {% set entries = craft.entries.section('featuredUsers').status(null).order('id desc') %} And then matched logged in user to post author, inside for loop {% elseif not entry.enabled and entry.authorId == currentUser.id %} – jarnof May 31 '16 at 14:45

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.