Skip to content

Instantly share code, notes, and snippets.

@sbrajesh
Created August 11, 2019 21:56
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sbrajesh/ba211d5b7023a67cf638bd073c77d9d0 to your computer and use it in GitHub Desktop.
Save sbrajesh/ba211d5b7023a67cf638bd073c77d9d0 to your computer and use it in GitHub Desktop.
Redirect BuddyPress User to their activity instead of home page
/**
* Redirect users to login if not not logged, otherwise, redirect to user activity.
*/
function buddydev_custom_user_home_page() {
if ( ! is_user_logged_in() ) {
bp_core_redirect( wp_login_url( site_url( '/' ) ) );
}
if ( is_front_page() ) {
bp_core_redirect( trailingslashit( bp_loggedin_user_domain() ) . bp_get_activity_slug() . '/' );
}
}
add_action( 'bp_template_redirect', 'buddydev_custom_user_home_page' );
@mohamettarik
Copy link

Hello and thanks for support, should we change (url) to my site url or leave it ?

@sbrajesh
Copy link
Author

No Need to do that. The code takes care of that.

Hello and thanks for support, should we change (url) to my site url or leave it ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment