2

I have the user submitting to a function that adds entries to a field called completed. It basically adds entries to each user showing the admin who has completed what.

I'm trying to figure out how to display a message on the front end that states if the user has completed the article. I need the message to stay on the front end for each entry that's been completed.

2

Assuming completed is an Entries field, and you want to test if a particular entry has been added to the currently logged in user's completed field, something like this'd work:

{% set isEntryCompleted = currentUser and entry.id in currentUser.completed.ids() %}

{% if isEntryCompleted %}
    ...
{% endif %}

The idea here is to first check if currentUser is set (it'll be null if the current user isn't logged in), and then pull an array of all selected entries' IDs with currentUser.completed.ids(). Finally you can use the in operator to check if a particular entry's ID is in that array.

  • So basically in this screen shot prnt.sc/kb1068 you can see the section name, Agree and Commit, then next to it has the amount of articles so in this case there's 5 in this section, on start of the section, it will be transparent / blank. As you start the bullets that are filled in are the completed tests, and the bullet that is outlined but not filled is the test you are currently on in the section. – Kevin Love Jul 25 '18 at 21:22

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.