Skip to:
Content
Pages
Categories
Search
Top
Bottom

Plugin: Force Login for Member Pages

Viewing 23 replies - 1 through 23 (of 23 total)
  • @wardeh

    Participant

    Awesome! I’m going to try it right now…

    @wardeh

    Participant

    Works! Thanks! I’m eager to try the other one(s) you’re working on…

    @nicolagreco

    Participant

    i am seeing used my suggests

    @dimensionmedia

    Participant

    Nice job Trent.

    @adamhdv

    Member

    Even better than the previous solution! Great work Trent! :]

    @mrk-1

    Participant

    I agree. This should definitely be enhanced for group pages!

    @nicolagreco

    Participant

    If trent send it to me, i will add it on the plugins directory, that i will open tomorrow at http://buddypressdev.org

    ;)

    @mikepratt

    Participant

    Trent. Excellent plugin. Thanks

    @dimensionmedia

    Participant

    Simple, but effective. Kudos Trent.

    @belogical

    Participant

    good stuff, works great. would also love to see it expanded to groups.

    @trent

    Participant

    I will extend it once I figure out a better way to do this. It would be best extended by adding in the components themselves for people using their own themes, but I did toy with just excluding all access to the theme. That isn’t as good if you use your own theme as you have to edit the plugin. Still working on it though!

    @enlightenmental1

    Participant

    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' );

    ?>

    @gpo1

    Participant

    I like the sound of this.. privacy for members && groups…

    I hope you would add this plugin to bpdev or wordpress.org for all to use?

    @davidtcarson

    Participant

    @gpo1. Burt already conquered this one. Just add a few lines to bp-custom.php. No plugin necessary.

    See https://buddypress.org/forums/topic.php?id=1651.

    Works for me!

    @internetado

    Participant

    @Trent Adams:

    Thank you, very usefull.

    @stefk

    Participant

    Hi Guys…the profile are private but cant seem to get the groups to become private too? Any suggestions?

    @trent

    Participant

    Simple way from Burtadsit :)

    <?

    function oci_restrict_access(){
    global $bp, $bp_unfiltered_uri;

    if (!is_user_logged_in() &amp;&amp;
    (BP_MEMBERS_SLUG == $bp_unfiltered_uri[0] ||
    BP_GROUPS_SLUG == $bp->current_component )){

    //bp_core_redirect( $bp->root_domain );
    bp_core_redirect(get_bloginfo('siteurl') . '/register');
    }
    }
    add_action( 'wp', 'oci_restrict_access', 3 );

    ?>

    Trent

    @jfcarter

    Participant

    Is there a way to force a login to view the member directory?

    Also, is there a mechanism to force a theme for all new user blogs? Even though I’ve disabled the default theme in the Site Admin panel, all new user blogs still have it.

    @peterverkooijen

    Participant

    @Stefk, try Burtadsit’s solution.

    Private members and groups sections should be a core feature of Buddypress imho.

    @djpaul

    Keymaster

    @Peter – privacy controls are something that is coming post-v1.

    @anemec

    Participant

    @DJPaul any ETA on how long after v1 it might be?

    Also is there any way to just limit members viewing privileges solely to the groups to which they are subscribed. So for instance if I, as a new member, sign up on a blog I could be automatically relegated to a specific private group. From there I would only be able to see and friend others in my own group?

    I haven’t dug around in the code too much to see about this but intend to. Has anybody done this that you know about?

    @cozzie

    Participant

    Hi Trent

    Thanks a lot for this super useful plugin

    I send users to to /wp-login.php and I hope to redirect them from here to the original link that they tried to view, do you have any idea how they can achieve this?

    I tried this:

    $ref = $_SERVER[‘HTTP_REFERER’];

    bp_core_redirect(get_bloginfo(‘siteurl’) . ‘/wp-login.php?redirect_to=’.$ref);

    but it sends users to the previously viewed page rather than the link they tried to view.

    For example if a user arrives at the homepage and clicks on a link they are sent to /wp-login.php to login, once logged in they are returned to the homepage not the page they wanted to view. This becomes more of a problem for users accessing the site from a link in an email (e.g. a friends invitation) because they are given no page to redirect to after logging in.

    thanks a lot, a lot for any help!!

    @mrk-1

    Participant

    Cozzie,

    bp_core_redirect( get_bloginfo('siteurl') . '/wp-login.php?redirect_to=' . urlencode( $bp->root_domain . $_SERVER['REQUEST_URI'] ));

    should work.

    But, while testing this, I figured out that the redirect_to doesn’t result in any effect? Even if a valid rediret_to parameter is given, users are always forwarded to the frontpage!? What’s wrong with redirect_to?

Viewing 23 replies - 1 through 23 (of 23 total)
  • The topic ‘Plugin: Force Login for Member Pages’ is closed to new replies.
Skip to toolbar