Skip to:
Content
Pages
Categories
Search
Top
Bottom

Redirect to Registration Page ["Plugin"]

  • @nickmy

    Participant

    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)
  • @xevo

    Participant

    @nexia

    Participant

    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.

    @wildrot

    Participant

    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”.

    @nexia

    Participant

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

    @mrk-1

    Participant

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

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

    @21cdb

    Participant

    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?

    @mrk-1

    Participant

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

    ?

    @21cdb

    Participant

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

    @fesko

    Participant

    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.
Skip to toolbar