Last active
April 20, 2018 18:21
-
-
Save actual-saurabh/69ffc5fc6943cea44a34a9d5edfacb4e to your computer and use it in GitHub Desktop.
Redirect LifterLMS users to different hub pages based on their membership
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 // Do not copy this line | |
// Copy from under this line and paste into your child theme's functions.php | |
add_filter( 'rul_before_user', 'llms_redirect_for_login', 10, 4 ); | |
function llms_redirect_for_login( $custom_redirect_to, $redirect_to, $requested_redirect_to, $user ){ | |
// get the student details for the user | |
$student = llms_get_student( $user ); | |
// not a student, don't redirect | |
if( ! $student ){ | |
return; | |
} | |
// the membership plan id for annual program | |
$membership_id = 1779; // from membership editor link: https://community.sensitiveevolution.com/wp-admin/post.php?post=1779&action=edit | |
// if student is enrolled in annual program, they are getting redirected correctly | |
if( $student->is_enrolled( $membership_id ) ){ | |
return $custom_redirect_to; | |
} | |
// replace the link with any new url that you'd like to use as a hub for self-study students | |
return 'https://community.sensitiveevolution.com/hub-2/'; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment