I have the same original issue as @dena_blaze and am also using the Profile Builder plugin. I added this code to my functions.php
file and it doesn’t seem to work.
I could try using the solution you had here of creating an entirely separate login page via Profile Builder and then setting a redirect to my Discourse forum homepage, but that seems like an unnecessary workaround, and it would be more ideal to use this solution since my understanding is that it would redirect the user back to the exact forum page they were looking at previously (not just the homepage as a catch-all).
Any updates on whether this has been added to the plugin’s code, and/or is it likely something may have changed with Profile Builder to need a different solution?