BuddyPress Login Redirect


/ Published in: PHP
Save to your folder(s)

I needed away to redirect to a custom BP component upon login for users and this works great. Add this to your functions file. If you are the admin, it will redirect you to the wp-admin.


Copy this code and paste it in your HTML
  1. <?php
  2. /*Add a filter to filter the redirect url for login*/
  3.  
  4. add_filter("login_redirect","bpdev_redirect_to_profile",100,3);
  5. function bpdev_redirect_to_profile($redirect_to_calculated,$redirect_url_specified,$user)
  6. {
  7.  
  8. /*if no redirect was specified,let us think ,user wants to be in wp-dashboard*/
  9. if(empty($redirect_to_calculated))
  10. $redirect_to_calculated=admin_url();
  11.  
  12. /*if the user is not site admin,redirect to his/her profile*/
  13. if(!is_site_admin($user->user_login))
  14. return bp_core_get_user_domain($user->ID).mypics;
  15. else
  16. return $redirect_to_calculated; /*if site admin or not logged in,do not do anything much*/
  17.  
  18. }
  19. ?>

URL: http://wordpress.stackexchange.com/questions/29545/login-redirect-to-certain-bp-profile-page

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.