Skip to:
Content
Pages
Categories
Search
Top
Bottom

Buddypress redirecting user after login


  • Abhijit Agarwal
    Participant

    @eclectic_solutions

    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);
    global $user;
    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*/
    	$user = wp_get_current_user();
    	if (in_array( "administrator", $user->roles ))
    		//return $redirect_to_calculated;
    		return admin_url();		
    	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. Please help.

  • The topic ‘Buddypress redirecting user after login’ is closed to new replies.
Skip to toolbar