I’m looking for a hand-coded solution to do the following:
-
in some pages (so, not every page) I want to redirect the users NOT logged in to the standard login page: when they login, they are automatically redirected to the page where they were;
-
same for some posts;
I tested many free plugins but I was really not satisfied: some moves the login form in the protected page, some other lets you put a link to the login page.
I’m quite surprised “vanilla WP” doesn’t offer a login option like the one I’m looking for: you can set a private post, but then it is really private (not to say invisible), then there’s a password solution, but I don’t see many website using this idea, it’s quite uncommon, imho.
Anyway, I would like to know where I can find information about how to code this behaviour myself: there are lots of resources but it looks like anybody has a “snippet” but nothing is “definitive”.