Info
- 7 posts
- 6 voices
- Started 3 years ago by Trent Adams
- Latest reply from jfcarter
- This topic is not resolved
Plugin: bbPress Force Login for Buddypress
-
- Posted 3 years ago #
I wanted a little plugin to allow Force Login on bbPress forum when you have integration with buddypress. I altered mdawaffe's plugin and thought I would share it with the community if you want privacy on forum and still work with buddypress.
<?php /* Plugin Name: Force Login Description: No one can see your forums unless they are logged in. Plugin URI: http://bbpress.org/forums/topic/117 Author: Michael D Adams *voodoo code from Trent Adams and Sam Bauers* Author URI: http://blogwaffe.com/ Version: 0.8 */ function force_login_init() { if ( !bb_is_user_logged_in() && 0 !== strpos($_SERVER['REQUEST_URI'], bb_get_option( 'path' ) . 'bb-login.php') && 0 !== strpos($_SERVER['REQUEST_URI'], bb_get_option( 'path' ) . 'bb-reset-password.php') && 0 !== strpos($_SERVER['REQUEST_URI'], bb_get_option( 'path' ) . 'register.php') && 0 !== strpos($_SERVER['REQUEST_URI'], bb_get_option( 'path' ) . 'xmlrpc.php') ) { nocache_headers(); header("HTTP/1.1 302 Moved Temporarily"); bb_safe_redirect( bb_get_uri( 'bb-login.php', null, BB_URI_CONTEXT_HEADER + BB_URI_CONTEXT_BB_USER_FORMS ) ); header("Status: 302 Moved Temporarily"); exit(); } } add_action( 'bb_init', 'force_login_init' ); ?>Cheers,
Trent
-
- Posted 3 years ago #
Hiya Trent :-)
-
- Posted 3 years ago #
Hi Trent, it's been a long time. Good to see you around this neck of the woods.
Thanks for sharing the plugin.
Is Buddypress any good?
-
- Posted 3 years ago #
Untested code cleanup (just for fun - untested)
function force_login_init() { if (!bb_is_user_logged_in() && !preg_match("/(bb\-login|bb\-reset\-password|register|xmlrpc)\.php/s",$_SERVER['REQUEST_URI'])) { nocache_headers(); header("HTTP/1.1 302 Moved Temporarily"); header("Status: 302 Moved Temporarily"); bb_safe_redirect( bb_get_uri( 'bb-login.php', null, BB_URI_CONTEXT_HEADER + BB_URI_CONTEXT_BB_USER_FORMS ) ); exit; } }Good to see you Trent, don't be a stranger!
-
- Posted 3 years ago #
I will be around more again now ;) Been a busy year! Thanks for the cleanup code _ck_ and I will test it tomorrow. Hi back to everyone ;)
Trent
-
- Posted 3 years ago #
$_SERVER['REQUEST_URI']can be dodgy, _ck_'s code cleanup is probably a little safer. -
- Posted 3 years ago #
Is this the most up to date code? I've tried to use it and I am getting no effect. No errors, nothing.
Is there a specific location where the plugin should reside (besides bb-plugins) or does it need a specific name?
Also, should the path just be the domain or something else?
-
You must log in to post.