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] Redirect to home if person is not logged in or if dont have access

Simple Membership Plugin › Forums › Simple Membership Plugin › Redirect to home if person is not logged in or if dont have access

Tagged: redirect

  • This topic has 1 reply, 2 voices, and was last updated 8 years, 11 months ago by mbrsolution.
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • January 3, 2018 at 12:50 am #12855
    GeorgeT1
    Participant

    Hi Guys.

    Trying to find code for my functions.php file:

    if someone is NOT logged in OR does NOT have access to a PAGE, then redirect to my home page.

    I did find the code below, but does not work (maybe because it refers to a Post vs Page (not sure it matters?))

    global $post;
    $post_id = $post->ID;//Grab the post ID
    $protection_ctrl = SwpmProtection::get_instance();
    //Check if the current visitor has access to this post.
    $is_protected = $protection_ctrl->is_protected($post_id);
    if($is_protected) {
    //This user doesn’t have permission to see this post. Redirect the user.
    $redirect_url = ‘http://example.com/redirect-page’;
    wp_redirect($redirect_url);
    exit;
    }

    THANK YOU!!

    January 3, 2018 at 3:42 am #12857
    mbrsolution
    Moderator

    Hi, did you check the following PHP Tweaks?

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