Closed vonscriptor closed 1 year ago
That would be because craft.wishlist.lists()
by default adds a query parameter to fetch lists for the current user, whether you specify a user or not. This is for ease-of-development, because most of the time you want to get the list of the currently logged-in user. It would be in fact dangerous to do otherwise (showing other users' lists), so it's there as a guard.
Changing to:
{% set followingList = craft.wishlist.lists(false).userId(user.id).type('following').one() %}
Should do the trick, if you want to force a user ID, but you also shouldn't have to do that. It will do this automatically: https://github.com/verbb/wishlist/blob/9078b32528e7c49d3c6a93a974fab4deb95321fe/src/variables/WishlistVariable.php#L33
Which sorts out what the current user is. In addition, this also handles getting the session-based list for guests, where a user ID doesn't exist.
See docs
Gosh that was simple—sorry I overlooked it. Thank you!
Describe the bug
Example:
{% set followingList = craft.wishlist.lists().userId(user.id).type('following').one() %}
If the user.id is 1 it will return null even though that user has that list.
This doesn't seem to happen when you're a currentUser (signed in).
There is additional odd behavior when you logout.
Steps to reproduce
Craft CMS version
4.3.1
Plugin version
2.0.3
Multi-site?
No
Additional context
I'm not sure how Craft CMS decides user ids, but my admin account is 1, then I have groups in 600's, 1500's, etc.