The answer to this post will answer your question. Just change the element IDs to match yours.
Close but not completely accurate.
The code mentioned in the above post is only checking if the user is already logged in. If they are, then you can do something.
The function that you need to use is onLogin : https://www.wix.com/corvid/reference/wix-users/onlogin
You would need to add it to your site tab. This means AFTER someone successfully logs in you can trigger the code to do something.
I recommend using a combination of both codes because when a user lands on your page they may already be logged in so you want to prepare for both scenarios not just one.