-
Author
-
January 10, 2015 at 13:18 #41577topdogParticipant
I want to redirect people based on the page they’re on when they login. The reason for this is my site has event registration so I want people to stay on the same screen when they login to purchase tickets. However, if they login via the homepage for example, they should be taken to their member profile.
I modified the code to redirect a user to their member profile after login but it’s not working for some reason. I added “is_front_page()” as a conditional which should check if a user is on the homepage but it’s not working properly. I also tried conditionals for specific pages, custom post types, and categories and that did work either.
Obviously I’m doing something wrong and hoping you can help.
COPY CODE/*Make sure profile is default component*/ define('BP_DEFAULT_COMPONENT','profile'); /*let us filter where to redirect */ add_filter("login_redirect","bpdev_redirect_to_profile",10,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(!is_site_admin($user->user_login) && is_front_page()) 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*/ }
January 10, 2015 at 19:18 #41591LauraModeratorHello, have you tried this plugin? https://wordpress.org/plugins/buddypress-login-redirect/
Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solutionLaura Solanes - Graphic Designer and Web Designer
Please be patient as I try to answer each topic as fast as i can.
If you like the theme or the support you've received please consider leaving us a review on Themeforest!
Always happy to help you 🙂
January 11, 2015 at 21:06 #41701topdogParticipantThanks for the plugin suggestion but you can’t choose a redirect per page with BP Login Redirect.
However, I believe found out way my code isn’t working. The ‘is_front_page()’ isn’t being recognized because people use the modal popup to login. Therefore, login is not being recognized on any specific page. That’s why if I try the code I posted earlier, it works when I use ‘!is_front_page()’ but never when I use ‘is_front_page()’ because the modal is never considered as the front page of the site.
Any suggestions on how to fix the code to recognize what page the modal popup is on? Another option is to have the login form pass a hidden variable depending on the page(s) the user is on when they login. I can use the variable to determine the redirect action.
I’d appreciate any advice you can give.
January 13, 2015 at 16:54 #41885AbeKeymasterHi, we will add this functionality in the next version so you will have a new option in Sweetdate – Miscellaneous to enable this.
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. -
AuthorPosts
The forum ‘Sweetdate – WordPress’ is closed to new topics and replies.