Last active
April 17, 2021 00:19
-
-
Save strangerstudios/c7b7b9ff6ff6e815bab1 to your computer and use it in GitHub Desktop.
Sample code to update login redirects for members
This file contains 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 | |
Plugin URI: http://www.paidmembershipspro.com/wp/pmpro-redirect/ | |
Description: Sample code to update login redirects for members | |
Version: .2 | |
Author: Stranger Studios | |
Author URI: http://www.strangerstudios.com | |
*/ | |
function my_pmpro_login_redirect_url($redirect_to, $request, $user) | |
{ | |
global $wpdb; | |
//if logged in and a member, send to members page | |
if(pmpro_hasMembershipLevel(NULL, $user->ID)) | |
return "/members/"; | |
else | |
return $redirect_to; | |
} | |
add_filter("pmpro_login_redirect_url", "my_pmpro_login_redirect_url", 10, 3); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thia recipe is included in the blog post on "Redirecting Members on Login" at Paid Memberships Pro here: https://www.paidmembershipspro.com/redirecting-members-on-login/