Simple Membership Plugin › Forums › Simple Membership Plugin › Auto Redirect Non Logged-in Users (Protect Whole Site)
- This topic has 7 replies, 2 voices, and was last updated 8 years, 4 months ago by
The Assurer.
-
AuthorPosts
-
April 16, 2018 at 1:28 pm #14136
it’s time
ParticipantHello,
I did add the following PHP code to my theme’s functions.php file:
/*** 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( ‘ https://portal.reset4success.biz/program/login/’ );
exit;
}
}
But I am getting an error message; unable to communicate back with site to check for fatal erroer, so the php change was revertedCan you give me a tip how to fix this?
Thanks a lot.
April 16, 2018 at 3:49 pm #14137The Assurer
ModeratorBut I am getting an error message; unable to communicate back with site to check for fatal erroer, so the php change was reverted
Was that the EXACT message?
April 16, 2018 at 4:01 pm #14138it’s time
Participanthallo, well there was a second sentence. Second sentence was, “you will need to upload your php file change by some other means, such as by using SFTP”
I tried to do that with Filezilla, but my whole website was not reachable anymore.
April 16, 2018 at 4:25 pm #14139The Assurer
Moderator…my whole website was not reachable anymore.
You might have “bigger problems” than you think. Please contact your hosting provider to determine why you can’t access your site anymore.
April 16, 2018 at 4:55 pm #14140it’s time
Participantthanks for your quick reply. Well, I changed it back to the original and then it was ok again. I could enter my website again.
Maybe I did paste the text in the wrong place?
where should it be added exactly?April 16, 2018 at 7:19 pm #14141The Assurer
ModeratorI’m going to respectfully suggest that you keep careful notes on EVERYTHING you do, to your site. Many problems are “self inflicted,” through carelessness.
1. Do you still receive the error message?
2. Are you a “real” PHP programmer?
April 17, 2018 at 1:36 pm #14159it’s time
Participanthello,
I am not a php programmer, but I track each step…. the only way to learn… My website is working again now. I just can’t stand that I cannot fix this last thing myself. Meanwhile, I use a wp plugin Buddypress Members only, but I thought it was not 100% stable. If you have any advice where I can add the text exactly in the theme’s functions.php file I would be very happy.
thanksApril 17, 2018 at 6:51 pm #14161The Assurer
ModeratorThe kind of auto-redirection you are trying to do, is outside the scope of the free technical support forum. If you still require coding help, please open a paid support ticket.
https://simple-membership-plugin.com/paid-support-simple-membership-plugin/ -
AuthorPosts
- You must be logged in to reply to this topic.