简体   繁体   中英

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

关于什么:

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

Below code is used to redirect the use to buddypress profile page after login

function bp_help_redirect_to_profile(){
  global $bp;
  if( is_user_logged_in() && is_front_page() ) {
   bp_core_redirect( get_option('home') . '/members/' . 
   bp_core_get_username( bp_loggedin_user_id() ) . '/profile' );
  }
}
add_action( 'get_header', 'bp_help_redirect_to_profile',1);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM