• Log In
  • Welcome
  • Features
  • Pricing
  • Documentation
  • Add Ons
  • Payment Gateways
  • Support
  • Showcase
  • Blog
  • Contact

Log In


Join Now | Lost Password?

Skip to content

Paid Memberships Pro

WordPress Membership Plugin
  • Log In
  • Choose a Plan
  • Features
    • Product Overview
    • Screenshots
    • About Us
  • Pricing
  • Documentation
  • Add Ons
  • Gateways
  • Support
  • Showcase
  • Blog
Home  >  Blog  >  Redirect Members to Referrer on Login
Kimberly Coleman

Redirect Members to Referrer on Login

Posted in FAQ, Recipes

Improve the user experience by redirecting members back to the protected content they just viewed. The steps below will show you how to set the referring URL in the messages displayed on protected posts or pages.

When a user clicks “Log In” on a piece of members-only content, they will be redirected back to that URL after successful login.

Redirect members to referrer when viewing locked content

Login Redirection Overview

Core WordPress login redirection is based on the user’s role. Paid Memberships Pro redirects all users, regardless of their role, to the Membership Account page.

You can read this documentation on redirect logic in PMPro to better understand the default redirects in the plugin.


Using the !!referrer!! attribute

The default “Message for Logged-out Users” (under Memberships > Settings > Advanced Settings) provides a link to “Log In” and a link to “Join Now”.

Update the “Log In” link to the following:

<a href="!!login_page_url!!?redirect_to=!!referrer!!">Log In</a>

This will redirect your member to the last piece of protected content they tried to view.

Note that if you have other plugins installed meant to redirect members on login, those settings may override this. Premium members can open a ticket in our support area for help with login redirects.

Redirect Login by Membership Level

This article demonstrates how to set up redirection back to the referring page. We have another article that demonstrates how to redirect members on login based on their membership level. This method can work in conjunction with the example in this guide and will only redirect the member if no referrer is passed to the login page URL.

Kimberly Coleman

Author: Kimberly Coleman

Kim is co-founder of Paid Memberships Pro. She has her hand in all aspects of the development, management, and marketing for the product and the team. She oversees frontend development for the core open source plugin and Add Ons.

Tagged: login redirect, pmpro_not_logged_in_text_filter, redirect. Bookmark the permalink. Last updated: May 17, 2020.

Post navigation

← Add a Custom Column to the Members List and All Users Admin Pages
How to Add a Conditional Log in and Log out Link to Your WordPress Menu →

Build a membership site—for free.

The fastest way to charge for access to your WordPress site. Our core plugin is free and includes more than other membership plugins. You deserve more.

Start for Free
Choose a Plan

We’re 100% GPL

Our plugin's code is not obfuscated, runs on as many sites as you want and can be customized to fit your project's needs. We just ask that you follow the GPLv2 guidelines by applying the GPLv2 license to any altered or unaltered version of PMPro that you distribute. License Details »

GPL v2

Recent Posts

  • How to Connect Paid Memberships Pro to Zoho CRM
  • Unsubscribe Members from MailChimp upon WordPress Account Deletion
  • How to Migrate from MemberPress to Paid Memberships Pro

Platform

  • Pricing
  • Features
  • Reviews
  • Screenshots
  • Videos
  • Compatibility

Add Ons

  • Free
  • Standard
  • Plus
  • User
  • Integration
  • View All

Get Help

  • Support
  • Download & Install
  • Hosting
  • Developers
  • Blog
  • Contact Us

Company

  • About Us
  • Work With Us
  • Brand Assets
  • Affiliates
  • Privacy Policy
  • Terms of Service
Follow Us On

© 2022 Paid Memberships Pro. All Rights Reserved.