BuddyBoss Home – Web › Support Forums › Themes › Boss. theme › Login Redirect to Buddypress Profile
Tagged: redirect
- This topic has 9 replies, 7 contibutors, and was last updated 8 years, 9 months ago by Anonymous.
Question
November 14, 2015 at 6:29 pm #51708@bptinnovationHi, any suggestions to redirect to buddypress profile page after logging in? I am currently using below in child theme’s function.php:
//NEW CUSTOM REDIRECT AFTER LOGIN PER ROLE */
function wc_custom_user_redirect( $redirect, $user ) {
// Get the first of all the roles assigned to the user
$role = $user->roles[0];$dashboard = admin_url();
$myaccount = get_permalink( wc_get_page_id( ‘myaccount’ ) );if( $role == ‘administrator’ ) {
//Redirect administrators to the dashboard
$redirect = home_url();
} elseif ( $role == ‘shop-manager’ ) {
//Redirect shop managers to the dashboard
$redirect = $dashboard;
} elseif ( $role == ‘editor’ ) {
//Redirect editors to the dashboard
$redirect = $dashboard;
} elseif ( $role == ‘author’ ) {
//Redirect authors to the dashboard
$redirect = $dashboard;
} elseif ( $role == ‘customer’ || $role == ‘subscriber’ ) {
//Redirect customers and subscribers to the “My Account” page
$redirect = $myaccount;
} elseif ( $role == ‘candidate’ ) {
//Redirect candidates to the “Home” page
$redirect = home_url();
} elseif ( $role == ’employer’ ) {
//Redirect employers to the “Home” page
$redirect = home_url();
} else {
//Redirect any other role to the previous visited page or, if not available, to the home
$redirect = wp_get_referer() ? wp_get_referer() : home_url();
}return $redirect;
}
add_filter( ‘woocommerce_login_redirect’, ‘wc_custom_user_redirect’, 10, 2 );Answers
November 14, 2015 at 6:54 pm #51710@bptinnovationI installed WordPress Social Login which successfully redirect’s to member’s profile page using code below in child theme’s functions.php, but still looking for suggestions on how to achieve when just logging in using woocommerce my account page.
function wsl_after_user_registration( $user_id, $provider, $hybridauth_user_profile, $redirect_to )
{
$user = get_userdata($user_id);if( $user && is_object( $user ) && is_a( $user, ‘WP_User’ ) ) {
if( $user->has_cap( ‘administrator’ ) ) {
$redirect_to = admin_url();
} else {
$redirect_to = home_url(‘/members/’. $user->user_nicename);
}
}add_action( ‘wsl_clear_user_php_session’ );
wp_safe_redirect( $redirect_to );
die();
}
add_action(‘wsl_hook_process_login_before_wp_safe_redirect’, ‘wsl_after_user_registration’, 10, 5 );November 16, 2015 at 3:14 am #51783@wrkazigmailtry BP Login Redirect plugin by Jatinder Pal Singh
November 16, 2015 at 5:49 am #51797@webezyHi I tried BP Login Redirect but it did not work. Also tried function wsl_after_user_registration and no success.
Does anyone know how to set login to redirect to member profile page on login and not WP dashboard?
November 18, 2015 at 2:04 pm #52080@bptinnovationBP Login Redirect plugin by Jatinder Pal Singh does not work for me either
November 19, 2015 at 1:14 am #52135@
AnonymousHi @bptinnovation, For woocommerce redirection try ‘WooCommerce Login Redirect’ plugin
Regards
PallaviNovember 19, 2015 at 5:47 pm #52242@kswc99me-comPeter’s Login Redirect works for me in Social Learner
November 20, 2015 at 6:27 am #52275@
AnonymousThanks @kswc99me-com for your suggestion 🙂
February 7, 2016 at 1:37 am #58374@schwarzaufweissadd_filter( 'bp_login_redirect', 'bpdev_redirect_to_profile', 11, 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( isset( $user->ID) && ! is_super_admin( $user->ID ) ) return bp_core_get_user_domain( $user->ID ); else return $redirect_to_calculated; /*if site admin or not logged in, do not do anything*/ }
Code provided by Brajesh Singh (buddydev.com)
February 8, 2016 at 5:41 am #58476@
Anonymous@schwarzaufweiss Thanks for your input
Regards
Varun Dubey
- The question ‘Login Redirect to Buddypress Profile’ is closed to new replies.