buddypress - custom login page redirect to logged in user profile page

admin2025-01-07  5

If I click on sign in then it should go to the login page.

The issue is that when I put the link then it goes to redirect_to home page, but I want to go on user profile page instead.

I don't want to use a plugin to redirect to profile page after login.

I have code for user profile - <a href="<?php echo bp_loggedin_user_domain(); ?>/profile/edit/"><span>My Profile</span></a>

And i want to put this link into <input type="hidden" name="redirect_to" value="<?php echo esc_attr($redirect_to); ?>" />

Is this possible? Are there other suggestions?

If I click on sign in then it should go to the login page.

The issue is that when I put the link then it goes to redirect_to home page, but I want to go on user profile page instead.

I don't want to use a plugin to redirect to profile page after login.

I have code for user profile - <a href="<?php echo bp_loggedin_user_domain(); ?>/profile/edit/"><span>My Profile</span></a>

And i want to put this link into <input type="hidden" name="redirect_to" value="<?php echo esc_attr($redirect_to); ?>" />

Is this possible? Are there other suggestions?

Share Improve this question edited Oct 27, 2017 at 7:35 Ravi Patel 5385 silver badges21 bronze badges asked Apr 9, 2014 at 11:21 PrekshaPreksha 411 silver badge3 bronze badges 8
  • Thanks for fast reply.... I tried with this code and put in bp-child->function.php but still it goes to home page. And my profile link is look like this "www.mysite.com/members/%username%/profile/edit" – Preksha Commented Apr 9, 2014 at 12:44
  • Since you are using a custom login page it is hard to guess what is happening. Post your code please. – s_ha_dum Commented Apr 9, 2014 at 12:54
  • I have another issue with this log in page when I click on activation link in mail after registration page, it goes to wp-login page so that I want to change with custom login page and then it goes to member profile page. – Preksha Commented Apr 9, 2014 at 13:13
  • 1 Maybe you do have multiple issues but that doesn't get me any closer to understanding the problem. Post your code. – s_ha_dum Commented Apr 9, 2014 at 13:17
  • Sorry but i don't get it. Do you need code of custom login page or fuction.php? – Preksha Commented Apr 9, 2014 at 13:37
 |  Show 3 more comments

3 Answers 3

Reset to default 0

If you're using the built in function to create the login box, one of the parameters is redirect. wp_login_form function reference

To get your profile link, check when you're logged in as admin. The link is the same, but the options presented are different. Default is yoursite.com/wp-admin/profile.php

You can write code in function in functions.php and add action to this

add_filter( 'login_redirect', 'my_rd', 10, 3 );

Function my_rd(){

}

IF you wants to use plguin bp redirect to profile go here:

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 much*/

}
转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1736265194a1026.html

最新回复(0)