Dynamic links when logged in/out
-
Hi,
I’m trying to set up a client area on a wordpress website, and a different URL needs to be in place depending on whether they are logged in or not. At the moment, I have this:
<?php if ( is_user_logged_in() ) { echo '<a href="https://www.website.co.uk/'.$current_user->user_login.'" id="link6"></a>';} else { echo '<a href="https://www.website.co.uk/wp-login.php" id="link6"></a>';}; ?>
When noone is logged in, the ‘else’ section works fine, but when they are logged in, it just shows as https://www.website.co.uk instead of e.g. https://www.website.co.uk/username
Is there anyway to do this?
Thanks for any help.
- The topic ‘Dynamic links when logged in/out’ is closed to new replies.