Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial


Susan Siow
Susan Siow
6,497 Points

Login Redirection to Current Page Snippet

Does anyone has a function snippet which can redirect WP users to their current viewing page when they are login?

2 Answers

Mike Bronner
Mike Bronner
16,395 Points

Try this: http://codex.wordpress.org/Function_Reference/wp_redirect

wp_redirect( $location, $status );

As long as you know what page they need to be redirected to, this should do that.

Susan Siow
Susan Siow
6,497 Points

But I need the full code of the redirection for function.php and I don't think it is as easy as below:

<?php echo wp_login_url( get_permalink() ); ?>

Please help.