How to Redirect to Current Page After Login In WordPress

I have a site that requires a login to view. Rather than redirect visitors to the home page after login, I thought it would be nice to include a redirect to the current page after login.

It turns out that WordPress handles this quite easily using the following code:

echo 'Login to view this content.';

I first found the idea from Ashfame, but then I found a better version via, which you see above.

Posted in

Toby Cryns

Toby Cryns is a freelance CTO, expert WordPress consultant, and teacher.

He offers free advice to improve your freelance biz.

He also publishes small droppings every now and then to and

Follow Toby's contributions on Github and