Retrieving the current user location as a URL?
-
Hi,
While creating some log in / log out links for my theme, I’ve run into a problem. I’d like to return the user to where he or she was on my site after he or she logs in or out, and fortunately this can be achieved using wp-login.php?redirect_to=https://example.com/ for logging in and wp_logout_url(‘https://example.com’) for logging out.
I cannot, however, seem to find a good way of retrieving the URL to return the users to. the_permalink() will only return post and page links, while get_category_link() will only return category links. Is there a more universal way of getting a link to the current user location?
If not, I could of course switch between the methods using a conditional. I’d have to determine whether the user is browsing a post/page or a category, in that case.
What should I do?
Any advice is appreciated!
- The topic ‘Retrieving the current user location as a URL?’ is closed to new replies.