Skip to:
Content
Pages
Categories
Search
Top
Bottom

Redirect to Registration Page ["Plugin"]

  • Profile photo of nickmy
    nickmy
    Participant

    @nickmy

    Hello

    this little code will redirect guest to the registration page:

    <?php

    if (!is_user_logged_in()) {

    header( ‘Location: register’ ) ;

    }

    ?>

    Open the index.php file in:

    wp-content/plugins/buddypress/bp-themes/bp-default

    and add it in to line 1.

    Best Regards

Viewing 9 replies - 1 through 9 (of 9 total)
  • Profile photo of Xevo
    Xevo
    Participant

    @xevo

    btw, your plugin here would redirect anybody in any situation to the registration page,… even google etc… i’m not sure this logic is good… let people browse your site, they will register if they see fit.

    Profile photo of Wildrot
    Wildrot
    Participant

    @wildrot

    btw, your plugin here would redirect anybody in any situation to the registration page,… even google etc…

    That’s not quite correct - only non-logged-in users are being redirected :p

    let people browse your site, they will register if they see fit.

    Agreed, partially at least: I’ve been running a BP community a while ago where I used a similar snippet: Guests could browse the site freely as long as they did not try to access members’ profiles. If they did, they were redirected to the registration page. Helped a whole lot to generate registrations - with a surprisingly low percentage of “dead accounts”.

    @Wilbrot, you have the example of a well managed community… ;)

    Profile photo of m@rk
    m@rk
    Participant

    @mrk-1

    Here’s a plugin to handle like Wildrot (and myself btw):

    https://buddypress.org/forums/topic/plugin-force-login-for-member-pages

    Profile photo of 21cdb
    21cdb
    Participant

    @21cdb

    Can i enter this thread with a question:

    I want my network only be visibe for logged in users. i put the following code in bp-custom.php but it leads to a redirct loop and i don’t see the mistake:

    function restrict_access() {

    global $bp, $bp_unfiltered_uri;

    if (!is_user_logged_in() ) {
    bp_core_redirect( $bp->root_domain . '/' . BP_REGISTER_SLUG );
    }
    }

    add_action( 'wp', 'restrict_access', 3 );

    Any hint for me?

    Profile photo of m@rk
    m@rk
    Participant

    @mrk-1

    Don’t know how BP_REGISTER_SLUG behaves, but have you tried

    bp_core_redirect( $bp->root_domain . '/register' );

    or

    bp_core_redirect( get_bloginfo( 'siteurl') . '/register' );

    ?

    Profile photo of 21cdb
    21cdb
    Participant

    @21cdb

    Just figured out the solution. I forgot to exclude BP_REGISTER_SLUG from (!is_logged_in):

    This solution works for me (put it in bp-custom.php)

    function restrict_access() {

    global $bp, $bp_unfiltered_uri;

    if (!is_user_logged_in() && (BP_REGISTER_SLUG != $bp->current_component )) {

    //bp_core_redirect( $bp->root_domain );
    bp_core_redirect( $bp->root_domain . '/' . BP_REGISTER_SLUG );

    }
    }

    add_action( 'wp', 'restrict_access', 3 );

    Profile photo of fesko
    fesko
    Participant

    @fesko

    How do i redirect members when they login to a new BP page (page i create??

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Redirect to Registration Page ["Plugin"]’ is closed to new replies.