php - Wordpress trigger login when coming from external link

one text

We have a webshop in wordpress which customers need to log into in order to access it. When sending links to products visitors are required to be logged in - before they click on the links - which is to say rather annoying and stupid really.

Is there a plugin or code that allow us to trigger a login popup when visitors come from external links (aka. email links). I imagine we can detect this looking for UrL variables. like:

www.example.com/store/#!/art/p/506411370/category=1230023

Basically we want to be able to check if the user is logged in, if not trigger the login-popup, and then redirect to the link they clicked on.

any ideas would be gratefully received. Thank you in advance.

Source