Tagged: intranet
Hello,
I was wondering what would be the best and safest way to create a wordpress/buddypress intranet. What I have done so far is checking if user is not logged and then redirect (to wp login url or to a custom login page:
‘if ( is_user_logged_in() ) {
return false;
}//refirect to wp-login or custom login page’
I guess most restricted wordpress sites rely on something similar, but I don’t now if this is the best and safest way.
Also, the above doesn’t stop anyone accessing an image url, for example.I would love to know your thoughts.
Regards
JavierHi Javier,
You are doing it correctly if you are using the conditional redirect to redirect users. That is the standard way in WordPress community.About the individual media url, though you can restrict it using .htaccess etc, It is not recommended. It is not scalable solution and even facebook does not restrict it. Try copying a private media url and then opening it directly in another browser from facebook. So, that is standard industry practice at the moment.
Hope that helps.
Regards
BrajeshThank you, Brajesh.
I remember doing that Facebook check while ago: I should have had that in mind.
One weird thing is happening now: if I set BuddyPress site-wide activity page as the frontpage, it bypasses the restriction and anyone can see… This works except for activity archives:
function restrict_site() {
if ( is_user_logged_in() ) {
return false;
}if ( function_exists( ‘bp_is_active’ ) ) {
if ( bp_is_activation_page() || bp_is_register_page() ) {
return false;
}
}$redirect_page = wp_login_url();
//Custom redirect page
$custom_redirect_page = get_page_by_title( ‘Login’ );if ( !empty( $custom_redirect_page ) ) {
if (get_permalink( $custom_redirect_page )) {
$redirect_page = get_permalink($custom_redirect_page);
// If we are actually on the redirect page – abandon
if ( is_page( $custom_redirect_page ) ) {
return false;
}
}
}wp_redirect( $redirect_page );
exit;}
add_action( ‘template_redirect’, ‘restrict_site’ );I think I’m missing something
Hi Javier,
Brajesh Sir is away so I am posting here. I have tried your code in bp-custom.php as well as current theme functions.php file and it is working for me. I have checked for SiteWide Activity case also. Try with some high priority
replace the line
add_action( ‘template_redirect’, ‘restrict_site’ );
with
add_action( ‘template_redirect’, ‘restrict_site’, 0 );
and let me know if it works or not.
Thank You
Ravi- This reply was modified 8 years, 5 months ago by Ravi.
You must be logged in to reply to this topic.