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

[Resolved] Hiding Code & Menu

Simple Membership Plugin › Forums › Simple Membership Plugin › Hiding Code & Menu

  • This topic has 8 replies, 2 voices, and was last updated 8 years, 3 months ago by Morgane.
Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • July 6, 2018 at 8:54 am #14859
    Morgane
    Participant

    Hi,

    My website has pages which contain sections I have coded on my own. Those code sections are visibles despite I’m not logged in, bellow the protected contend message. The “non-coded” (made with the theme) content is well hidden.
    I would like to hide those code sections for not logged in users, like my pages non-coded content are hidden. How can I do ?

    Moreover, is it a way to hide menu for non logged in users ? Not only for the login page (I can use a template for that), but for all my website pages ?

    I hope I’m enough clear, thank’s in advance

    July 6, 2018 at 3:36 pm #14863
    The Assurer
    Moderator

    Since you seem to be a competent PHP programmer, have a look at these PHP coding tweaks, you can use:
    https://simple-membership-plugin.com/simple-membership-miscellaneous-php-tweaks/

    July 16, 2018 at 7:39 am #14929
    Morgane
    Participant

    Thank’s for your answer. I tried to code it on my own but it doesn’t work. So I find in the documentation this code :

    /***  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(17089) || !is_page(17117) || !is_page(17091) || !is_page(17119) || !is_page(17087) || !is_page(17110) ) ) {
            wp_redirect( 'https://knowledgecenter.buymanager.biz/en/membership-login/' );
            exit;
        }
    

    But it didn’t work either. It’s wrote that my website is redirect too many time. Do you know why ?

    July 16, 2018 at 12:35 pm #14930
    The Assurer
    Moderator

    It’s wrote that my website is redirect too many time.

    Huh? I think something was “lost in translation.” Please provide a screenshot of the actual message, EXACTLY as it appears.

    July 17, 2018 at 8:43 am #14936
    Morgane
    Participant

    redirected too many time

    Sorry, I wrote it to fast without thinking :/
    If you cannot see the screenshot, here the real message :
    “This page isn’t working
    knowledgecenter.buymanager.biz redirected you too many times.
    Try clearing your cookies.
    ERR_TOO_MANY_REDIRECTS”

    July 20, 2018 at 2:02 pm #14956
    Morgane
    Participant

    July 20, 2018 at 4:28 pm #14957
    The Assurer
    Moderator

    If I point ANY of my browsers to: knowledgecenter.buymanager.biz I receive the following messages:

    
    Warning: include(): https:// wrapper is disabled in the server configuration by allow_url_include=0 in /home/buymanag/knowledgecenter/wp-content/plugins/sitepress-multilingual-cms/inc/request-handling/redirection/wpml-rootpage-redirect-by-subdir.class.php on line 47
    
    Warning: include(https://knowledgecenter.buymanager.biz/fr): failed to open stream: no suitable wrapper could be found in /home/buymanag/knowledgecenter/wp-content/plugins/sitepress-multilingual-cms/inc/request-handling/redirection/wpml-rootpage-redirect-by-subdir.class.php on line 47
    
    Warning: include(): Failed opening 'https://knowledgecenter.buymanager.biz/fr' for inclusion (include_path='.:/usr/local/php5.6/lib/php') in /home/buymanag/knowledgecenter/wp-content/plugins/sitepress-multilingual-cms/inc/request-handling/redirection/wpml-rootpage-redirect-by-subdir.class.php on line 47
    

    You seem to have a plugin called: sitepress-multilingual-cms
    Please try disabling it.

    July 23, 2018 at 1:09 pm #14976
    Morgane
    Participant

    Good afternoon.

    It’s “normal” you have this error message, actually the correct URL is https://knowledgecenter.buymanager.biz/en/ (I haven’t create the redirection yet).

    And even if I deactivate the plugin, the problem is still here.

    N.B. : if you try to go on the site, you won’t see the page
    “This page isn’t working
    knowledgecenter.buymanager.biz redirected you too many times.
    Try clearing your cookies.
    ERR_TOO_MANY_REDIRECTS”
    because I remove the code

    /***  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(17089) || !is_page(17117) || !is_page(17091) || !is_page(17119) || !is_page(17087) || !is_page(17110) ) ) {
            wp_redirect( 'https://knowledgecenter.buymanager.biz/en/membership-login/' );
            exit;
        }

    when I’m working on it…

    August 2, 2018 at 7:44 am #15108
    Morgane
    Participant

    Finnaly I put this code in the function.php file and it works

    function redir() {
    	$location = get_site_url() . "/en/membership-login/";
    	 if(!SwpmMemberUtils::is_member_logged_in() && !is_page( array(17117, 17089, 17091, 17119, 17087, 17110) )) {
            wp_redirect( $location, 301 );
            exit;
        }
    }	
    add_action( 'template_redirect', 'redir' );

    Like that members are auto-redirect to login page when they’re not logged. 17117, 17089, … correspond to the ID of login page, registering page, password forget page, …

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