Created
April 9, 2019 20:32
-
-
Save greathmaster/b0d29eaa2bdf2f2651b6d4ecbe1f4eac to your computer and use it in GitHub Desktop.
PMPro confirmation URL redirection based on discount code AND membership level
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
function my_pmpro_confirmation_url($rurl, $user_id, $pmpro_level) | |
{ | |
global $wpdb; | |
$code = $wpdb->get_row("SELECT * FROM $wpdb->pmpro_discount_codes WHERE id = $pmpro_level->code_id LIMIT 1"); | |
/* | |
Example of $code content: | |
object(stdClass) { | |
public 'id' => string '7' (length=1) | |
public 'code' => string 'SC916E8F9CC' (length=11) | |
public 'starts' => string '2019-04-08' (length=10) | |
public 'expires' => string '2029-04-08' (length=10) | |
public 'uses' => string '100' (length=3) | |
} | |
*/ | |
if(isset($code)) { | |
if($code->code == 'SC916E8F9CC' && pmpro_hasMembershipLevel(1)) | |
$rurl = "http://example.com/page_1"; | |
if($code->code == 'X84HJ8F9CC' && pmpro_hasMembershipLevel(2)) | |
$rurl = "http://example.com/page_2"; | |
if($code->code == 'JU486E8F9CC' && pmpro_hasMembershipLevel(3)) | |
$rurl = "http://example.com/page_3"; | |
} | |
return $rurl; | |
} | |
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