Skip to:
Content
Pages
Categories
Search
Top
Bottom

Re: Plugin: Force Login for Member Pages


enlightenmental1
Participant

@enlightenmental1

awesome mod…. thanks for making this

quick question(s) for anyone who knows:

I have added an else $is_single_group to the php in order to limit viewing groups to members only, but I’m not sure what to use for the “$is_single_group”

it’s almost there… next I would add two more else’s to limit viewing the /members and /groups pages to members only… but I dunno what the variables are..

<?php

/*

Plugin Name: Force Member Login

Description: No one can see your member pages unless they are logged in.

Plugin URI: http://trentadams.ca

Author: Trent Adams

Author URI: http://trentadams.ca

Version: 0.1

*/

function force_member_login_init() {

global $bp, $is_member_page, $is_single_group;

if ( $is_member_page) {

if ( !is_user_logged_in() ) {

echo "<center>";

echo "<div align='center' style='background:#f1f1f1; border:2px dashed #990000; width:450px;'>

";

echo "<h1>You must be logged in to view member profiles</h1>";

echo "click here to login or register

";

echo "</div>";

sleep(5);

//nocache_headers();

//header("HTTP/1.1 302 Moved Temporarily");

//header('Location: ' . get_settings('siteurl') . '/register');

//header("Status: 302 Moved Temporarily");

echo "</center>";

exit();

}

}

else {

if ( $is_single_group) {

if ( !is_user_logged_in() ) {

echo "<center>";

echo "<div align='center' style='background:#f1f1f1; border:2px dashed #990000; width:450px;'>

";

echo "<h1>You must be logged in to view group profiles</h1>";

echo "click here to login or register

";

echo "</div>";

sleep(5);

//nocache_headers();

//header("HTTP/1.1 302 Moved Temporarily");

//header('Location: ' . get_settings('siteurl') . '/register');

//header("Status: 302 Moved Temporarily");

echo "</center>";

exit();

}

}

}

}

add_action( 'init', 'force_member_login_init' );

?>

Skip to toolbar