It depends whether you want to redirect people to the target page before they log in or after they login.
This code ensures that if they login on the target page they will remain on the target page.
So, for example, if you already have customers segmented in your Newsletter Mailer (e.g. MailChimp) or CRM (e.g. Insigtly) then you can email them links that take them to the target page and this code ensures when they log in that they stay on that page.
You could also disable the S2Member login redirect and use a redirection plug-in like https://en-au.wordpress.org/plugins/redirection/
There are many paths to the outcome.
It would be easier for others to assist if you mapped out how users would get to where you want to get them…e.g.
- You already know who they are pre-login and can redirect them via custom url before they hit the site
- You already know who they are pre-login and can have a landing page that can redirect them to the appropriate target page when they access the page
- You don’t know who they are pre-login BUT you can have a landing page that has a form that asks a question that is used to know which page to redirect them to
- etc, etc