Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Plugin to work with PMPro and PMPro User Pages to redirect someone to their latest user page on login.
<?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
You can’t perform that action at this time.