Membership Plugin

WordPress Membership Plugin

  • Home
  • Documentation
  • Addons
  • Support
    • Quick Setup
    • Documentation
    • Premium Addon Support
    • Paid Support
    • Support Forum
    • Support Forum Search
    • Forum Login
    • Forum Registration
  • Contact

[Support request] Auto Redirect Non Logged-in Users (Protect Whole Site)

Simple Membership Plugin › Forums › Simple Membership Plugin › Auto Redirect Non Logged-in Users (Protect Whole Site)

Tagged: 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.
Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • April 16, 2018 at 1:28 pm #14136
    it’s time
    Participant

    Hello,

    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 reverted

    Can you give me a tip how to fix this?

    Thanks a lot.

    April 16, 2018 at 3:49 pm #14137
    The Assurer
    Moderator

    But 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 #14138
    it’s time
    Participant

    hallo, 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 #14139
    The 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 #14140
    it’s time
    Participant

    thanks 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 #14141
    The Assurer
    Moderator

    I’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 #14159
    it’s time
    Participant

    hello,

    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.
    thanks

    April 17, 2018 at 6:51 pm #14161
    The Assurer
    Moderator

    The 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/

  • Author
    Posts
Viewing 8 posts - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.
Log In

Please read this message before using our plugin.

Search

Featured Addons and Extensions

  • Membership Form Builder Addon
  • Member Directory Listing Addon
  • WooCommerce Payment Integration
  • Member Data Exporter Addon

Documentation

  • Documentation Index Page

Copyright © 2026 | Simple Membership Plugin | Privacy Policy