Skip to:
Content
Pages
Categories
Search
Top
Bottom

Plugin: Force Login for Member Pages

Viewing 23 replies - 1 through 23 (of 23 total)

  • Wardee
    Participant

    @wardeh

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


    Wardee
    Participant

    @wardeh

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


    nicolagreco
    Participant

    @nicolagreco

    i am seeing used my suggests


    David Bisset
    Participant

    @dimensionmedia

    Nice job Trent.

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


    m@rk
    Participant

    @mrk-1

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


    nicolagreco
    Participant

    @nicolagreco

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

    ;)


    Mike Pratt
    Participant

    @mikepratt

    Trent. Excellent plugin. Thanks


    David Bisset
    Participant

    @dimensionmedia

    Simple, but effective. Kudos Trent.


    belogical
    Participant

    @belogical

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

    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

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

    ?>


    gpo1
    Participant

    @gpo1

    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?


    David Carson
    Participant

    @davidtcarson

    @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

    @internetado

    @Trent Adams:

    Thank you, very usefull.


    stefk
    Participant

    @stefk

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

    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

    @jfcarter

    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

    @peterverkooijen

    @Stefk, try Burtadsit’s solution.

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

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


    anemec
    Participant

    @anemec

    @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?


    Kieran
    Participant

    @cozzie

    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!!


    m@rk
    Participant

    @mrk-1

    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