WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Im trying to do a redirect to a certain bp profile page but for some reason it keeps going to the home page on the login.

this is my code im not entirely sure what the problem is and why it keeps going to the home page.

add_action('login_form', 'redirect_after_login');
function redirect_after_login() {
    global $redirect_to;
    if (!isset($_GET['redirect_real'])) {
        $redirect_to = bp_core_get_user_domain($user->ID);
        $redirect_real = '$redirect_to/mypics';
share|improve this question
try to exit; after the redirect. – kaiser Sep 26 '11 at 21:33
that made my login button disappear – Jeremy Love Sep 26 '11 at 22:24

this one works better imho, not my code btw :)

put it in /plugins/bp-custom.php

    //=Redirect to User's Profile Page after Login
    function rt_login_redirect($redirect_to, $set_for, $user){
    $redirect_to = bp_core_get_user_domain($user->id);
    return $redirect_to;
    add_filter('login_redirect', 'rt_login_redirect', 20, 3);
share|improve this answer
up vote 0 down vote accepted

I was able to find success with this function from BP Redirect to Profile (see GitHub repository):

Plugin Name: BP Redirect to Profile for Buddypress
Description:Redirect user to their profile when they login
Version: 1.1
Requires at least: BuddyPress 1.1
Tested up to: BuddyPress 1.2+wpmu 2.9.1
License: GNU General Public License 2.0 (GPL) http://www.gnu.org/licenses/gpl.html
Author: Brajesh Singh
Author URI: http://buddydev.com
Plugin URI:http://buddydev.com/buddypress/bp-redirect-to-profile-plugin-redirect-users-to-their-profile-on-login-on-buddypress-sites/
Last updated:16th feb 2010
    Copyright (C) 2009 Brajesh Singh(buddydev.com)

    This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or  any later version.

    This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

    You should have received a copy of the GNU General Public License along with this program; if not, see <http://www.gnu.org/licenses>.

/*Add a filter to filter the redirect url for login*/
function bpdev_redirect_to_profile($redirect_to_calculated,$redirect_url_specified,$user)
/*if no redirect was specified,let us think ,user wants to be in wp-dashboard*/

    /*if the user is not site admin,redirect to his/her profile*/
        return bp_core_get_user_domain($user->ID).mypics;
        return $redirect_to_calculated; /*if site admin or not logged in,do not do anything much*/

share|improve this answer
Note that you are not allowed to remove an explicit copyright notice. I fixed that for you. Next time do it right from start. Thanks. – toscho May 15 '12 at 5:00

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.