Redirect to Previous Page - Please Clarify Process

Ok, I guess I’m just looking for confirmation/clarification on this process…

I read this api functions doc on the pro_widget: https://www.s2member.com/codex/stable/s2member/api_functions/package-functions/#src_doc_s2member_pro_login_widget()

And, this forum topic, which helped give an idea where to put the “%%previous%%” code - including allowing it to place in the s2 login shortcode: https://forums.wpsharks.com/t/redirect-to-previous-page-after-login-not-working/4778

Now, here’s my situation:
Scenario 1:
User receives an email, with link to post ‘A.’
Post ‘A’ has S2 Level 1 (or higher) protected/locked content.
When user clicks link to post ‘A,’ they are redirected to the login page, because content is protected. (So, they technically don’t even visit the post ‘A’ page/content.)
User logs in.
Login page reloads, showing user summary.
User is NOT redirected to post ‘A’, as they previously clicked and intended to visit.

Scenario 2:
User receives email, with link to category page (unprotected).
User clicks a link from categories page, leading to post that is protected, thus redirecting them to a login page.
User logs in.
Login page reloads with user summary
User is NOT redirected to previous page - neither the categories page nor the actual post they clicked that was protected.

Questions:

  1. Is adding the option login_redirect="%%previous%%" to the S2Member login shortcode the correct method? If not, can someone provide an example of where it should added and how it should look? (I attempted the api-functions.php file, and received red flags in the code. So, I’m assuming that’s not correct, either.)

  2. Do I need to remove the S2Member Post Restriction from the post, and add the [s2If current_user_can(access_s2member_level1)] shortcode to hide the content? My theory is, that the User clicks the link, arrives at Post ‘A’. Sees some (or none) content, and to read all of it the user must log in. Then they are redirected back to this content of Post ‘A.’

Any clarification of this process would be greatly appreciated.

Thanks!

Hi,
I’m not using s2Member pro_widget but if I understand This Page, you can use the [s2Member-Login /] shortcode in your destination page with “login_redirect” configuration of your choice!
Thanks.

Thanks Brice. I appreciate the link. I’ll give that a try!!

Hi Brice, Any thoughts as to why that wouldn’t work? Apparently, after going back to look at my code, I already had the %%previous%% as shown the KB article you linked to, but the user isn’t redirected to the previous page.