Yes exactly.
Ideally I want the member to go to a page and then be assigned a badged based on a certain set of criteria.
The criteria for my first two badges were based on number of likes on a post, and number of views on a post.
Right now I cannot incorporate both the currently logged in member and the criteria into the code all at once.
I want this code to only run for the currently logged in member. So in the very first code screenshot I sent, the criteria were working properly, but it awarded the button to every single member who met the criteria every time anyone arrived on that page. This happened because my topPostOwners array was being sent to my assignMembers function, but I can’t figure out how to extract the currently logged in member from that array and apply the assignMembers function only to them.
I’m not sure if I’m making it clear, so I’d like to offer an example:
Eric logs into the website. He made a forum post last week that has now reached over 50 likes.
There is a badge called “Tenured” that is awarded to the currently logged in member when they navigate to a page called “Claim Badges” if they are the owner of a post with more than 50 likes.
When Eric navigates to the"Claim Badges" page, the code runs to determine if the current member, Eric, is eligible for any badges.
If Eric already has the “Tenured” badge, the code will not reassign the badges.
If Eric does not have the “Tenured”, the code will check if he is eligible for that badge.
The code determines that Eric is eligible for the “Tenured” badge because he is the owner of a post with more than 50 likes.
Therefore, he is awarded that badge shortly after arriving on the “Claim Badges” page.
No members other than the currently logged in member are ever considered for any badges. This way they will not be awarded a badge more than once will not receive any notifications.
The exact same scenario happens simultaneously for other badges called “Patron” “Virtuoso” etc.
I know that’s a very long message… hope it’s clear! Thank you so much, Amanda!