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

Auto redirect when a user not login

Simple Membership Plugin › Forums › Simple Membership Plugin › Auto redirect when a user not login

  • This topic has 9 replies, 2 voices, and was last updated 9 years, 2 months ago by mbrsolution.
Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • September 15, 2017 at 11:44 am #11975
    hrc
    Participant

    I saw this link.
    https://simple-membership-plugin.com/auto-redirect-non-logged-in-users-protect-whole-site/

    But that creates infinity loop in Wp-admin page.
    How should I do to avoid WP admin tool loop problem?

    September 16, 2017 at 5:58 am #11976
    mbrsolution
    Moderator

    Hi, something else in your site is conflicting with the above function. Can you share what your function looks like?

    Thank you

    September 16, 2017 at 7:00 am #11977
    hrc
    Participant

    mbrsolution, Thanks. Here’s my code.

    add_filter( 'pre_get_posts', 'swpm_auto_redirect_non_members' );
    function swpm_auto_redirect_non_members() {
        if( !is_admin() && !SwpmMemberUtils::is_member_logged_in() && !is_page( array( 'membership-login', 'membership-join' )) ) {
            wp_redirect( 'http://example.com/membership-login/' );
            exit;
        }
    }

    If you are under published page, it’s OK. But if you are in admin page, it doesn’t work correctly.

    September 16, 2017 at 8:31 am #11978
    mbrsolution
    Moderator

    Just one question is example.com your actual domain name? Or did you not included for security reasons?

    September 16, 2017 at 8:54 pm #11982
    hrc
    Participant

    Ah, you’re correct. Actual url is here.
    http://lifestyle-supportguide.com/

    I think it’s plain wprdpress page.

    September 16, 2017 at 9:26 pm #11983
    mbrsolution
    Moderator

    So if you add the following URL http://lifestyle-supportguide.com/membership-login to your code does it work?

    September 16, 2017 at 10:55 pm #11984
    hrc
    Participant

    You mean like this?

    add_filter( 'pre_get_posts', 'swpm_auto_redirect_non_members' );
    function swpm_auto_redirect_non_members() {
        if( !is_admin() && !SwpmMemberUtils::is_member_logged_in() && !is_page( array( 'membership-login', 'membership-join' )) ) {
            wp_redirect( 'http://lifestyle-supportguide.com/membership-login/' );
            exit;
        }
    }

    Actually, I did.
    But in my administration tool(under /wp-admin), it created infinity loop with “too many redirect”.

    September 16, 2017 at 11:12 pm #11985
    mbrsolution
    Moderator

    Hi, I have submitted a message to the plugin developers to investigate further your issue.

    Thank you

    September 17, 2017 at 12:22 am #11987
    hrc
    Participant

    So what should I do?

    September 17, 2017 at 12:48 am #11988
    mbrsolution
    Moderator

    Hi, just wait until you hear from the developers. They will reply to this post.

    Kind regards

  • Author
    Posts
Viewing 10 posts - 1 through 10 (of 10 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