-
Author
-
November 21, 2013 at 23:15 #7052
knuhkles
ParticipantI love this theme more and more.. Its getting better and better. Is their a way to redirect to a certain page after login? i dont want to use another plugin if their is a way already.
November 21, 2013 at 23:28 #7053adam
Participantthis will redirect users to their profile when they log-in and the administrator (you) to wp-admin:
COPY CODE/* Filter the redirect url for login*/ add_filter("login_redirect","kleo_redirect_to_profile",100,3); function kleo_redirect_to_profile($redirect_to_calculated,$redirect_url_specified,$user){ /*if no redirect was specified,let us think ,user wants to be in wp-dashboard*/ if(!is_super_admin($user->ID)) return bp_core_get_user_domain($user->ID ); else return $redirect_to_calculated; /*if site admin*/ }
it goes in the functions.php file of your child theme. is this what you’re looking for?
November 24, 2013 at 04:07 #7151SQadmin
Keymasterso instead of: return bp_core_get_user_domain($user->ID ); put return ‘/my_page_link’;
Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solutionNovember 24, 2013 at 18:32 #7172knuhkles
Participantok so the final code should be this…
COPY CODE/* Filter the redirect url for login*/ add_filter("login_redirect","kleo_redirect_to_profile",100,3); function kleo_redirect_to_profile($redirect_to_calculated,$redirect_url_specified,$user){ /*if no redirect was specified,let us think ,user wants to be in wp-dashboard*/ if(!is_super_admin($user->ID)) return '/my_page_link'; else return $redirect_to_calculated; /*if site admin*/ }
November 26, 2013 at 15:49 #7273SQadmin
KeymasterYes that is correct
Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solutionDecember 6, 2013 at 22:59 #7817hughm
ParticipantI am using the above code to try and redirect first time log-ins to the change-avatar page. I tried the following code but it did not work. Am I making a syntax mistake?
return ‘/USERNAME/profile/change-avatar/’;
I used some code in my functions.php file to change the path of member profiles to get rid of “members” and display at the root of the url.
December 7, 2013 at 07:19 #7841hughm
ParticipantThis is the code I use in my child theme functions.php to put profile names at the root. Perhaps this is conflicting with above code?
// put profiles in the root
define ( ‘BP_ENABLE_ROOT_PROFILES’, true );December 9, 2013 at 10:27 #7925SQadmin
KeymasterHi, You should look at @adam’s code: https://archived.seventhqueen.com/forums/topic/redirect-after-login-2#reply-7053
and change from the root of the profile to the change avatar page by changing:
return bp_core_get_user_domain($user->ID );
with
return bp_core_get_user_domain($user->ID ).’/profile/change-avatar/’;Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solutionDecember 9, 2013 at 18:25 #7983hughm
ParticipantI tried this code and played around with it but couldn’t make it work. I am trying to take first time log-ins to the change avatar page. This code takes new users to the login page on first login:
/*if the user is not site admin,redirect to his/her profile*/
if(!is_super_admin($user->ID))
return bp_core_get_user_domain($user->ID ).’/profile/change-avatar/’;Any ideas?
December 9, 2013 at 18:33 #7986knuhkles
ParticipantHere guys… this is my snippet… it works
add_action( ‘template_redirect’, ‘my_redirect_home’ );
function my_redirect_home()
{
if( is_user_logged_in() && is_front_page() )
{
wp_redirect( site_url( ‘/logged-in’ ) );
exit();
}
}December 9, 2013 at 19:21 #7990hughm
ParticipantSorry to say I couldn’t get it to work. The below gets me to the new user profile but can’t seem to get the next step to the change-avatar page.
if(!is_super_admin($user->ID))
return bp_core_get_user_domain($user->ID );December 10, 2013 at 12:16 #8063Abe
KeymasterHi, Like I said:
You should look at @adam‘s code: https://archived.seventhqueen.com/forums/topic/redirect-after-login-2#reply-7053
and change:
return bp_core_get_user_domain($user->ID );
with
return bp_core_get_user_domain($user->ID ).’/profile/change-avatar/’;what you have pasted is just some part of the code
Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution---
@ SeventhQueen we do our best to have super happy customers. Thanks for being our customer.December 10, 2013 at 16:47 #8073hughm
ParticipantHi thanks,
Yeah, I did insert the piece of code into Adam’s and still couldn’t get it to work. Here is the entire code that I tried:/* Filter the redirect url for login*/
add_filter(“login_redirect”,”kleo_redirect_to_profile”,100,3);function kleo_redirect_to_profile($redirect_to_calculated,$redirect_url_specified,$user){
/*if no redirect was specified,let us think ,user wants to be in wp-dashboard*/
if(!is_super_admin($user->ID))
return bp_core_get_user_domain($user->ID ).’/profile/change-avatar/’;
else
return $redirect_to_calculated; /*if site admin*/This redirects back to the home page.
December 11, 2013 at 20:36 #8131Abe
KeymasterThat looks good. You should have your child theme activated.
Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution---
@ SeventhQueen we do our best to have super happy customers. Thanks for being our customer.December 16, 2013 at 10:50 #8322road2love
ParticipantHey there, I’m having the same problem, activated the child theme and entered the code to child-theme functions.php like it shows in Adams post..but couldn’t get it to work. When my users login they’re not redirected to their profile page but back to the homepage and it looks like they have to login again. Then when clicking on any other page the profile button top right appears.
Do you mind me asking knuhkles where exactly put your snippet of code?
December 17, 2013 at 00:28 #8401Abe
KeymasterHi, That code works, just added it to sweetdate-child/functions.php. Is the same code as here: https://archived.seventhqueen.com/forums/topic/redirect-user-to-their-profile-after-login
Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution---
@ SeventhQueen we do our best to have super happy customers. Thanks for being our customer.December 17, 2013 at 16:39 #8445hughm
ParticipantI noticed that @road2love was having trouble getting this to work. I never was able to make this code redirect to the change-avatar page. The code above failed and redirects to the home page. I ended up settling on just redirecting to the profile page, but if someone figures out how to get it to work please let me know.
December 20, 2013 at 17:02 #8631Abe
KeymasterThe code base is in this topic:
https://archived.seventhqueen.com/forums/topic/redirect-user-to-their-profile-after-loginmodified it should look like:
COPY CODE//custom redirect add_filter("login_redirect","kleo_redirect_to_profile",100,3); function kleo_redirect_to_profile($redirect_to_calculated,$redirect_url_specified,$user){ /*if no redirect was specified,let us think ,user wants to be in wp-dashboard*/ if(!is_super_admin($user->ID)) return bp_core_get_user_domain($user->ID ).'/profile/change-avatar/#item-nav'; else return $redirect_to_calculated; /*if site admin*/ }
You must be a regular user, not an admin
Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution---
@ SeventhQueen we do our best to have super happy customers. Thanks for being our customer.February 25, 2014 at 10:47 #11420sermsak
Participanti already add the code from https://archived.seventhqueen.com/forums/topic/redirect-user-to-their-profile-after-login . and i test to register. the page said – User registration is currently not allowed.
Please comment . Thank youFebruary 25, 2014 at 13:08 #11422sermsak
ParticipantHello. Support Team
Now i can fix this problem by wordpress help. Sorry to loose your time.
ThanksFebruary 27, 2014 at 15:51 #11572Abe
KeymasterHi, enable registration from Settings – General
Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution---
@ SeventhQueen we do our best to have super happy customers. Thanks for being our customer.April 8, 2014 at 11:09 #14552metalmick
ParticipantYep! This works… just done it! Thanks!
https://archived.seventhqueen.com/forums/topic/redirect-user-to-their-profile-after-login
-
AuthorPosts
The topic ‘Redirect After Login’ is closed to new replies.