WordPress.org

Ready to get started?Download WordPress

Forums

Get Referring Post Permalink (11 posts)

  1. linedrive
    Member
    Posted 2 years ago #

    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.

  2. Jeff Clark
    Member
    Posted 2 years ago #

    pass the permalink as a parameter and execute it after login is successful and use that permalink to redirect them.

  3. linedrive
    Member
    Posted 2 years ago #

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

  4. Jeff Clark
    Member
    Posted 2 years ago #

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

  5. linedrive
    Member
    Posted 2 years ago #

    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

  6. Jeff Clark
    Member
    Posted 2 years ago #

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

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

  7. linedrive
    Member
    Posted 2 years ago #

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

  8. Jeff Clark
    Member
    Posted 2 years ago #

    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.

  9. linedrive
    Member
    Posted 2 years ago #

    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?

  10. Jeff Clark
    Member
    Posted 2 years ago #

    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.

  11. linedrive
    Member
    Posted 2 years ago #

    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...

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.