Created
August 27, 2015 20:18
-
-
Save messica/a431d3c5fde3e7b1fa45 to your computer and use it in GitHub Desktop.
Redirect to last post viewed instead of confirmation page
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /* | |
| * Remember last post ID | |
| */ | |
| function my_wp() { | |
| global $post, $pmpro_pages; | |
| //don't track pmpro pages | |
| if( ! in_array($post->ID, $pmpro_pages)) | |
| setcookie('last_post_viewed', $post->ID, null, '/'); | |
| } | |
| add_action('wp', 'my_wp'); | |
| /* | |
| * Change login link in confirmation email to append last viewed post | |
| */ | |
| /* | |
| * Redirect to last post instead of Confirmation page | |
| */ | |
| function my_pmpro_confirmation_url($url, $user_id, $level) { | |
| if(!empty($_COOKIE['last_post_viewed'])) | |
| $url = get_the_permalink($_COOKIE['last_post_viewed']); | |
| return $url; | |
| } | |
| add_filter('pmpro_confirmation_url', 'my_pmpro_confirmation_url', 10, 3); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment