'How to make a link / button redirect to a different address based on which user clicks it [closed]

To make it simple, i have a menu that contains the items "W", "X", "Y" and "Z". Each item redirects to a different page on the website, regardless of the user. But i want item "Z" specifically to redirect to a different page depending on the user. For example, if user "1" clicks on "Z", then he will be redirected to the page example.com/z1. If it is user "2" who clicks on "Z", then he will be redirected to example.com/z2. And so forth.

Something like:

  • if user = user1, then button_Z = <p><a href="http://reddit.com/">Z</a></p>

  • if user = user2, then button_Z = <p><a href="http://youtube.com/">Z</a></p>

User1 is redirected to reddit, while user2 is redirected to YouTube.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source