@ronia you should put bp-custom.php file into the wp-content/plugins folder. Don’t put it into plugins/buddypress. Becasue bp-custom is a custom file which runs before your BP plugin. So that’s how it works.
@bennadler I didn’t use your code but I re-uploaded all files into the root directory and it worked.