Running a successful membership site is all about the member experience. If your site is difficult to navigate or your content poorly organized, members may lose interest, which means less engagement—and more churn.

One of the things you can do to improve the user experience is to automatically redirect members back to the protected content they were viewing right before they logged in. This enables them to log into your site without interrupting their engagement with your content.

In this tutorial, we will guide you through how to do this, so that when members click “Log In” on a piece of members-only content, they will be redirected back to that same URL immediately upon logging in.

Redirect members to referrer when viewing locked content

Login Redirection Overview

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

In order to change this default behavior, you’ll need to set the referring URL in the messages displayed on protected posts or pages.

🛠️ Check out our documentation on redirect logic in PMPro to better understand the default redirects in the plugin.

Using the !!referrer!! Attribute

Under Memberships > Settings > Advanced, you’ll find Message Settings, where the default “Message for Logged-out Users” will be populated with two HTML <a> tags:

  • the “Log In” link, and
  • the “Join Now” link.

To use the referrer attribute, simply replace the “Log In” <a> tag’s URL with !!login_page_url!!?redirect_to=!!referrer!! so that the tag looks like this:

<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 that are supposed 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 tutorial shows you how to set up redirection back to the referring page, but you can also redirect members to pages based on their membership level. You can even use both together, which would redirect member based on their membership level if no referrer is passed to the login page URL from WordPress, Paid Memberships Pro, or another plugin.