WordPress.org

Support

Support » How-To and Troubleshooting » Get Referring Post Permalink

Get Referring Post Permalink

  • linedrive
    Member

    @linedrive

    We have some protected pages on our site. If a user is not logged in, it redirects to the login page. How to we find the permalink for the link that was clicked prior to the redirect?

    get_permalink() shows the permalink for the login page, not the intended post. Thanks for the help.

Viewing 10 replies - 1 through 10 (of 10 total)
  • pass the permalink as a parameter and execute it after login is successful and use that permalink to redirect them.

    linedrive
    Member

    @linedrive

    thanks. any code to achieve that would be appreciated…thx

    are a plugin to protect pages? If so what is it.

    linedrive
    Member

    @linedrive

    we are using our own code in a theme to protect some pages – no plugin.

    Also get_permalink() does show the previous page/post. What we want to find is the intended page/post permalink, from the link clicked on the previous page/post

    add this to the top of any page you want to protect:

    <?php if(!is_user_logged_in()) : auth_redirect(); endif; ?>

    linedrive
    Member

    @linedrive

    Thanks, but we’re trying to find the permalink of the link that was clicked. We have no problem with restricting access…

    I must not understand what you are trying to do then. I am under the assumption that if the user is not logged in the page will redirect to login and after login it will redirect to the page they were restricted from? Please correct me where I am wrong.

    linedrive
    Member

    @linedrive

    User is on mysite.com/post1

    Clicks link to go to mysite.com/post2, which is protected and

    redirects to mysite.com/login

    We know the permalink for post1 as well as for login

    We need to know the permalink for post2

    Is there a wordpress function that will give us that info?

    may I ask why you need the permalink or post2?

    I ask because it depends on what you want to do with it then we can figure out how it needs to be passed or stored as a variable.

    linedrive
    Member

    @linedrive

    we need to store it as a variable, as we need to search the permalink for other strings, to be stored as hidden fields in the login form…

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Get Referring Post Permalink’ is closed to new replies.