Skip to:
Content
Pages
Categories
Search
Top
Bottom

Re: Login re-direct


Boone Gorges
Keymaster

@boonebgorges

OK, I cobbled together a solution. Two steps:

  1. Add the following code to your bp-custom.php folder or in your child theme’s functions.php (or a plugin if you roll that way):
    function myprofile_redirect() {
    global $bp;

    if ( $bp->current_component == 'myprofile' && $bp->loggedin_user->domain != '' ) {
    bp_core_redirect( $bp->loggedin_user->domain );
    } elseif ( $bp->current_component == 'myprofile' ) {
    bp_core_redirect( $bp->root_domain );
    }

    }
    add_action( 'plugins_loaded', 'myprofile_redirect');

  2. In header.php of your child theme (copy it over from bp-sn-parent if you don’t have one there already) replace

    <input type="hidden" name="redirect_to" value="<?php echo bp_root_domain() ?>" />

    around line 57 with

    <input type="hidden" name="redirect_to" value="<?php print ( bp_root_domain() . '/myprofile' ) ?>" />

Anytime a logged-in user types in the address http://example.com/myprofile, they’ll get their profile. Non-logged-in visitors will be redirected to the home page.

Let me know if it works for you.

Skip to toolbar