forked from strangerstudios/paid-memberships-pro
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinvoice.php
33 lines (26 loc) · 836 Bytes
/
invoice.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
<?php
global $current_user, $pmpro_invoice;
if($current_user->ID)
$current_user->membership_level = pmpro_getMembershipLevelForUser($current_user->ID);
if (!is_user_logged_in()) {
wp_redirect(pmpro_url("account"));
exit;
}
//get invoice from DB
if (!empty($_REQUEST['invoice']))
$invoice_code = sanitize_text_field($_REQUEST['invoice']);
else
$invoice_code = NULL;
if (!empty($invoice_code)) {
$pmpro_invoice = new MemberOrder($invoice_code);
//var_dump($pmpro_invoice);
if (!$pmpro_invoice->id) {
wp_redirect(pmpro_url("account")); //no match
exit;
}
//make sure they have permission to view this
if (!current_user_can("administrator") && $current_user->ID != $pmpro_invoice->user_id) {
wp_redirect(pmpro_url("account")); //no permission
exit;
}
}