Disable Member page to non-logged in users
-
Hi BuddyPress,
I want to keep my site as private as possible.
I would like to disable access to non-logged in users to the members directory or any other profile related pages. If they do try to access then they get re-directed to homepage.Please could you send me the php I need to add to my functions.php to achieve this??
Many Thanks
-
Have you tried this plugin?
The plugin works fine. But there’s no option to hide the text “Members” when not signed in. It only redirects the user. That’s not really a good solution. Or am i totally wrong?
It works great. Thank you Prashant Singh. Fast answer aswell!
However, do you know how i can change the text? I need it to another language. I can change some of the text but not text in the form? Any suggestions?
You can use this plugin https://wordpress.org/plugins/loco-translate/ to translate/change the text.
If it is a single text please let me know, I will provide a code snippet for that then there will be no need to install a plugin for just one text change.
It’s working pretty good! Thanks for everything. I do still have some other small problems. If you can fix it, you’re my hero today! (even thou you already are now. Shhh..)
This is my post:
How to hide the “Home” tab under Profile (member navigation items)
Thanks for the appreciation 🙂
Please check my reply there.
Just a simple snippet.
//Hide for non-logged-in users (public visitors) function bp_logged_out_page_template_redirect() { if( ! is_user_logged_in() && is_page( 'members' )|| is_page( 'activity' ) || bp_is_user() ) { wp_redirect( home_url( '/register/' ) ); exit(); } } add_action( 'template_redirect', 'bp_logged_out_page_template_redirect' );
The snippet will do:
IF the user is not logged-in..
AND the page name is ‘members’ OR ‘activity’ OR bp-profile-page..
THEN it will redirect to REGISTER page.this works, but only if the url of the page has only MEMBERS, if there is the username MEMBERS / USER does not work.
Is there any way to solve this?//Hide for non-logged-in users (public visitors)
function bp_logged_out_page_template_redirect() {
if( ! is_user_logged_in() && is_page( ‘members’ )|| is_page( ‘activity’ ) || bp_is_user() ) {
wp_redirect( home_url( ‘/register/’ ) );
exit();
}
} add_action( ‘template_redirect’, ‘bp_logged_out_page_template_redirect’ );This code works, but now I can’t see the profile page. Every time I try I’ll get redirected to the register page. Even when I am logged in.
Can someone help me solve this?
sofoort,
Try adding another pair of parenthesis to the if statement
if( ! is_user_logged_in() && (is_page( ‘members’ )|| is_page( ‘activity’ ) || bp_is_user()) )
Full code:
//Hide for non-logged-in users (public visitors)
function bp_logged_out_page_template_redirect() {
if( ! is_user_logged_in() && (is_page( 'members' )|| is_page( 'activity' ) || bp_is_user()) ) {
wp_redirect( home_url( '/register/' ) );
exit();
}
} add_action( 'template_redirect', 'bp_logged_out_page_template_redirect' );All 3 of these options (BP Simple Private, Buddypress Lock, or the custom code) all cause significant page speed issues. (like 3 seconds)
Any suggestions to combat the privacy issue without compromising speed?
The custom code worked! Thank you.
Thanks silsbyc it’s working for me your snippet
Hello
When I install that plugin (https://wordpress.org/plugins/lock-my-bp/) it works perfectly – except now, my existing buddypress registration and login (with custom signup questions) is now replaced by what looks like standard WP Login/Register fields.Q: how can I disable keep my original Login/Register signup page/fields?
(I cannot see any shortcodes in my exiating BuddyPress register page to enter in lock-my-bp ‘Custom Form’ field – it’s blank)The page I need help with: https://www.101christianchat.com/members/
@epgb101 you can test https://wordpress.org/plugins/buddy-registration-widget/ it offers a shortcode for the register page, which can be used in plugin settings.
In our next update, we are going to provide options to map any custom page to display restricted content which will give you better content over the content.
How to hiding members page from non logged in users ?
//Hide for non-logged-in users (public visitors) function bp_logged_out_page_template_redirect() { if( ! is_user_logged_in() && is_page( 'members' )|| is_page( 'activity' ) || bp_is_user() ) { wp_redirect( home_url( 'https://vvcares.com/?buddypressBlogPostRedirect' ) ); exit(); } } add_action( 'template_redirect', 'bp_logged_out_page_template_redirect' );
Ref; https://vvcares.com/blog/post/wordpress-buddypress-hide-page-from-non-members
Hi!!
- You must be logged in to reply to this topic.