BuddyBoss Home – Web Support Forums Themes Boss. theme Login Redirect to Buddypress Profile

Tagged: 

Viewing 10 posts - 1 through 10 (of 10 total)
  • Question

    #51708
    @bptinnovation

    Hi, 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

    #51710
    @bptinnovation

    I 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 );

    #51783
    @wrkazigmail

    try BP Login Redirect plugin by Jatinder Pal Singh

    #51797

    Hi 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?

    #52080
    @bptinnovation

    BP Login Redirect plugin by Jatinder Pal Singh does not work for me either

    #52135

    Anonymous
    @

    Hi @bptinnovation, For woocommerce redirection try ‘WooCommerce Login Redirect’ plugin

    Regards
    Pallavi

    #52242
    @kswc99me-com

    Peter’s Login Redirect works for me in Social Learner

    https://wordpress.org/plugins/peters-login-redirect/

    #52275

    Anonymous
    @

    Thanks @kswc99me-com for your suggestion 🙂

    #58374
    @schwarzaufweiss
    
    add_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)

    #58476

    Anonymous
    @

    @schwarzaufweiss Thanks for your input
    Regards
    Varun Dubey

Viewing 10 posts - 1 through 10 (of 10 total)
  • The question ‘Login Redirect to Buddypress Profile’ is closed to new replies.