I see you added some logic for BuddyBoss Theme. However, the issue is with BuddyBoss Platform Plugin.
Probably a correct approach is to remove add_filter(?'site_url',?array(?$this,?'site_url'?),?10,?4?);
filter before calling $this->filter_wp_login_php(?$url,?$scheme?);
once the filter_wp_login_php
is executed you can add it back again.
My understanding is that if the hook is not removed, it will keep calling until the memory is used up.
Thanks