A visitor to your site has attempted to access some protected content. This may be either fully protected so that they are redirected to the Error Core Page, or partially protected so that visitors see some teaser content. In order to see the full content, they must login. After logging in, the member is immediately directed to the "Home Page" you have defined in the Member Homepage Settings.
Changing this behavior to redirect the member back to the protected content they previously attempted to view requires custom functionality. A MemberMouse customer named Thiago shared a solution with us, and gave us permission to publish it. Since then, several other customers have contributed suggestions and updates. The result of these efforts is a plugin that you may download and install on your site.
PLEASE NOTE: Although MemberMouse is sharing this 3rd party approach, we are unable to perform customizations for your unique circumstances, or provide technical assistance should the code not function as expected.
For many customers, simply installing and activating the plugin will provide the desired effect. By default, it will record of the location of any protected page visited, and redirect the member back to that page after login.
- Click here to download the plugin
- Open your WordPress Admin panel
- In the left column, select Plugins > Add New
- At the top, click Upload Plugin
- Click Choose File and select the downloaded plugin
- Click Install Now
- Click Activate
It's recommended that you test that redirection is working after installation. You can do this using a test member account and an Incognito/Private Browsing window. To verify that everything is working, you will need to visit one of your protected pages, proceed to the login page, and then log in using your test member account.
Note that members will be redirected back to the protected content even if their access rights do not permit them to view it. This will result either in redirection to the Error Core Page, or the display of teaser content. It's recommended that you test using a piece of protected content available to your test member.
Although this plugin does not provide adjustable settings in the WordPress administrative panel, you may change it's behavior in several ways by making some simple adjustments to the source code. Note that any mistakes made while editing the plugin source could result in your site becoming inaccessible. Please ensure that you have access to your site via FTP/SFTP, or the file manager in your hosting control panel, before making any changes. If you should experience any issues, you may follow these third-party instructions to disable the plugin.
To start, visit Plugins > All Plugins and ensure that the MM Redirect on Login plugin is Disabled. Editing an active plugin is not recommended. Next, you may access the plugin code as follows:
- In the left column of the admin panel, select Plugins > Plugin Editor
- If a warning appears, read it, and click I understand
- At the top-right, use the drop-down menu to select MM Redirect on Login
- Click Select to load the plugin for editing
The values that you can change are located on lines 11-15:
$_mmrl_redirectCookie = "mmrl_redirect_id";
This line sets the name of the cookie where the Post ID that the plugin will redirect back to after login is stored. In general, you should not need to change this setting, unless by some chance the default name conflicts with existing third-party functionality.
$_mmrl_redirectPeriod = 3600;
This sets the lifetime of the redirection cookie. The value is in seconds, and the default lifetime is one hour.
$_mmrl_redirectUnprotected = FALSE;
By default, the plugin will not attempt to redirect a member back to any unprotected pages they may have visited. Changing this value to TRUE will cause the plugin to record the location of unprotected pages as well. Note that MemberMouse Core Pages, such as the Checkout page, are automatically excluded from redirection.
$_mmrl_otherRedirectorIDs = array();
When a member logs in, MemberMouse will redirect them to the member home page associated with their membership level. However, some third-party plugins will override this behavior. An example of this is Thrive Apprentice, when using it's built-in login features. You may insert a comma-separated list of WordPress Page IDs between the parenthesis on this line, and whenever a logged-in member with a pending redirection visits these pages, they will be redirected to the previously-visited page. Here's an example that will enable redirection on Page ID 12345:
$_mmrl_otherRedirectorIDs = array(12345);
Instructions for locating a Page or Post ID can be found in this third-party article. Since some third-party plugins, including Thrive Apprentice, don't allow you to access their system pages via the WordPress Editor, you may need to login as a test member, and use the steps in the section Finding ID with Browser’s Inspection Tool.
$_mmrl_ignoreRedirection = array();
There may be several pages on your site that you don't want a member redirected back to after login. This is especially true if you have chosen to enable redirection back to unprotected pages. For example, if a logged-out member visited a protected page, and then subsequently visited your unprotected home page in the course of logging in, you wouldn't want the member redirected to the home page after login. MemberMouse Core Pages are automatically excluded from redirection. As before, instructions for locating a Page or Post ID can be found in this third-party article. Here's an example that will prevent redirection from being set on Page IDs 234, 345, and 456:
$_mmrl_ignoreRedirection = array(234, 345, 456);