Last active
July 30, 2020 07:02
-
-
Save strangerstudios/6911783 to your computer and use it in GitHub Desktop.
Plugin to work with PMPro and PMPro User Pages to redirect someone to their latest user page on login.
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 | |
/* | |
Plugin Name: PMPro Redirect to User Page | |
Plugin URI: http://www.paidmembershipspro.com/wp/pmpro-redirect-to-user-page/ | |
Description: Plugin to work with PMPro and PMPro User Pages to redirect someone to their latest user page on login. | |
Version: .2 | |
Author: Stranger Studios | |
Author URI: http://www.strangerstudios.com | |
*/ | |
/* | |
Login redirect example using PMPro to check membership levels. | |
*/ | |
function pmpror2up_login_redirect($redirect_to, $request, $user) | |
{ | |
//is there a user to check? | |
if(!empty($user->ID)) | |
{ | |
//check for a user page | |
$user_page_id = get_user_meta($user->ID, "pmproup_user_page", true); | |
//go to page | |
if(!empty($user_page_id)) | |
{ | |
//make sure the page exists | |
$url = get_permalink($user_page_id); | |
if(!empty($url)) | |
return $url; | |
else | |
return home_url(); | |
} | |
else | |
{ | |
return home_url(); | |
} | |
} | |
} | |
add_filter("login_redirect", "pmpror2up_login_redirect", 10, 3); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment