I have installed buddypress and now want that all users/members except admin should be redirected to groups page after login. I have written the code in a file mu-plugins/bp-custom.php
<?php add_filter("login_redirect", "bp_my_groups_redirect",10,3);
function bp_my_groups_redirect($redirect_to_calculated,$redirect_url_specified,$user) {
if(empty($redirect_to_calculated))
{
$redirect_to_calculated=admin_url();
}
setcookie("bp-groups-scope", "personal");
/*if the user is not site admin,redirect to his/her groups*/
if (current_user_can('create_users'))
return $redirect_to_calculated;
else
return "/groups";
}
?>
But, now all the members are getting redirected to groups page along with administrators. I want to redirect the administrators to wp dashboard. Please let me know the correct code.