Search code examples
wordpressbuddypress

How to redirect logged users to a custom page in buddypress & wordpress


I am trying too redirect every logged users to a specific page of their profile...See this example page.. this site is build on wp and bp. I am using BP Profile as Homepage plugin for logged in user redirection... this see this code ...

function bp_profile_homepage()
{
   global $bp;
   $selected_role = get_option('bpahp_role_choice');
   if($selected_role == '')
   {
       if(is_user_logged_in() && bp_is_front_page())
       {
            wp_redirect( $bp->loggedin_user->domain );
       }
   }
   else
   {
       if(!current_user_can($selected_role) && bp_is_front_page())
       {

            wp_redirect( $bp->loggedin_user->domain );
       }
   }
}

So after using this plugin i am able to redirect my user to their profile page automatically when they logged in.. http://www.example.com/members/admin/

but i want to redirect them to this page

http://www.example.com/members/admin/activity/all-activity/

All activity is a sub page of activity directory in which i am showing all activities to users sitewide.. i do not want to send them on site wide activity page for seeing activity i want to show them all that on their profile page..

So any idea what to add in this code wp_redirect( $bp->loggedin_user->domain );

to make it workable with my requirement.... I have tried so many tricks for making my requirement workable but do not get success..i have also tried to replace this code

wp_redirect( $bp->loggedin_user->domain );

with this one... $redirect_url = "$bp->loggedin_user->domain/activity/all-activity/";
wp_redirect( $redirect_url );

And this one

$redirect_url = "activity/all-activity/";   
    wp_redirect( $bp->loggedin_user->domain/$redirect_url );

Nothing is working Please somebody help me..


Solution

  • What about:

    wp_redirect( $bp->loggedin_user->domain . '/activity/all-activity/' );