Helping you Build Your Own Social Network!

Faster, better and easier!

14 Responses to Buddypress trick:Redirect Users to their profile on login

  • Pingback: BP Redirect to profile Plugin :redirect Users to their profile on Login on buddypress sites | Buddy Dev

  • is this working with WPMU or WPSU too?

  • Thanks for the trick, it works @ buddypress!

    I’m just wondering,
    if I want site admin also be redirected to his profile, what should I change in

    if(!is_site_admin($user->user_login))

    Thanks!

    • Hi Natalie,
      Thanks for the comment.

      Please change this

      if(!is_site_admin($user->user_login))
      return bp_core_get_user_domain($user->ID );
      else
      return $redirect_to_calculated; /*if site admin or not logged in,do not do anything much*/

      to


      return bp_core_get_user_domain($user->ID );

      That should do it.

  • Hi Brajesh,

    I’d like to have two different home pages: one for logged users and other for non-logged users. What I have to change in your code to redirect the user to a specific the home page for logged-users? I don’t want to use the profile page as home page.

    Thank you!

    • Hi Tazek,
      what will be the urls for the logged in user/non logged in user, I mean you will be using something like site.com/abc for logged in or non logged in, please let me know in a little detail and I will put the code.

      Thanks
      Brajesh

  • Hi Brajesh,

    Suppose that my website URL is: http://www.tazek.com.

    If a non-logged user visit this URL, then I want to display only the public content and also links to login form and register form.

    If a logged user visit this URL, then I want to redirect him to http://www.tazek.com/private/, then I want to display the private content.

    I don’t know how to:
    - Check if the user is logged and redirect him to the private website (www.tazek.com/private) if he’s logged;
    - Check if the user is logged and redirect him to the public website (www.tazek.com) if he isn’t logged;
    - Always redirect the user to http://www.tazek.com/private/ the log-on process.

    Thank you!

  • Hi Brajesh, I wrote something wrong. The last line is:
    - Always redirect the user to http://www.tazek.com/private/ after the log-on process.

  • Well this is what worked for me i Downloaded it ran into a few errors.
    This is what fixed it all so it works great hope it helps people in the future.
    Keep the good work up.

    <?php
    /*
    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 .

    /*Add a filter to filter the redirect url for login*/

    add_filter(“login_redirect”,”bpdev_redirect_to_profile”,100,3);

    function bpdev_redirect_to_profile($redirect_to_calculated,$redirect_url_specified,$user)
    {
    if(empty($redirect_to_calculated))
    $redirect_to_calculated=admin_url();

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

    }
    if ( !function_exists( ‘is_site_admin’ ) ) :
    function is_site_admin() {
    return is_super_admin();
    }
    endif;
    ?>

  • I’m just trying to figure out the code I would need to determine if a user is an admin or group admin, and if so display ABC set of links, but if not display XYZ set of links. I’ve been playing around with the code here a bit but no luck.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Get Adobe Flash playerPlugin by wpburn.com wordpress themes