- This topic has 1 reply, 2 voices, and was last updated 6 years, 2 months ago by .
Viewing 2 posts - 1 through 2 (of 2 total)
Viewing 2 posts - 1 through 2 (of 2 total)
- You must be logged in to reply to this topic.
WordPress Membership Plugin
Simple Membership Plugin › Forums › Simple Membership Plugin › Redirect to original page on a site that is fully protected
Tagged: protected site, redirect
Hi,
on the wordpress site I am trying to set up, I have done the following.
I installed the plugin: Simple Membership After Login Redirection
Everything was working well when I installed it. When a user reached a password protected page, they would have to click “Login” which brought them to the login prompt screen and when they logged in, it would automatically redirect them back to the original page they had accessed and wanted to read.
We wanted the whole site to be password protected so that people could not see anything without logging in, so we changed our PHP settings, using this article.
Auto Redirect Non Logged-in Users (Protect Whole Site): https://simple-membership-plugin.com/auto-redirect-non-logged-in-users-protect-whole-site/
However, now when a user (who is not logged in) clicks any part of the site (such as an article), they are brought automatically to the login page. But when they login, they are brought to the home page? I would like them to be redirected back to the page they were trying to access in the first place. Is there anything in the code for PHP I have to change?
/*** Auto redirect a user who isn’t logged into the site ***/
add_filter( ‘pre_get_posts’, ‘swpm_auto_redirect_non_members’ );
function swpm_auto_redirect_non_members() {
if( !SwpmMemberUtils::is_member_logged_in() && !is_page( array( ‘membership-login’, ‘membership-join’ )) ) {
wp_redirect( ‘http://www.your-domain.com/membership-login’ );
exit;
}
}
Hi, I have already replied to your other forum post.
https://wordpress.org/support/topic/redirect-to-original-page-on-a-site-that-is-fully-protected/#post-12346306
I am marking this one as resolved.
Thank you