Redirecting Email Notification Links to Login Page

Hey WPMU Dev community! I’ve recently found something that I will need assistance correcting on my BuddyPress website.

When a user clicks the a link that is in an email notification about something specifically related to their account (ex: some activity stream content, friend request to be accepted or rejected, etc.) and the user is not logged into the site, they see the “Page not Found” error page.

This is happening for obvious reasons, but instead of the user facing this rather confusing error, does anyone have any suggestions for making these links follow the below logic:

if the user is logged in, continue to the URL from the email.

else, redirect to the login page.

for now, leave the login page as mydomain.com/login

Would someone help out with this? Thank you.