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.
-
AuthorPosts
-
July 6, 2018 at 8:54 am #14859
Morgane
ParticipantHi,
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 #14863The Assurer
ModeratorSince 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 #14929Morgane
ParticipantThank’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 #14930The Assurer
ModeratorIt’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 #14936Morgane
ParticipantSorry, 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 #14956Morgane
Participant
July 20, 2018 at 4:28 pm #14957The Assurer
ModeratorIf 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 47You seem to have a plugin called: sitepress-multilingual-cms
Please try disabling it.July 23, 2018 at 1:09 pm #14976Morgane
ParticipantGood 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 #15108Morgane
ParticipantFinnaly 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, …
-
AuthorPosts
- You must be logged in to reply to this topic.