Membership custom filters?

This is the code I have been told to add to the functions.php file.

add_filter( 'ms-ajax-login-redirect', 'my_custom_login_redirect', 99, 2 );

function my_custom_login_redirect( $url, $user_id ) { <===================================== $user_id is empty

$member = MS_Factory::load( 'MS_Model_Member', $user_id );

foreach( $member->subscriptions as $subscription )

{

$membership = $subscription->get_membership();

$membership_name = $membership->name;

break;

}

return 'http://domain.com/?user=' . $member->username . '&profile=' . $membership_name;
}

The problem is that if I add it to functions.php or mu-plugin the $user_id is always empty.