Diff: STRATO-apps/wordpress_03/app/wp-content/plugins/paid-memberships-pro/preheaders/invoice.php
Keine Baseline-Datei – Diff nur gegen leer.
1
-
1
+
<?php
2
+
3
+
global $current_user, $pmpro_invoice;
4
+
5
+
//get invoice from DB
6
+
if ( ! empty( $_REQUEST['invoice'] ) ) {
7
+
$invoice_code = sanitize_text_field( $_REQUEST['invoice'] );
8
+
} else {
9
+
$invoice_code = NULL;
10
+
}
11
+
12
+
// Redirect non-user to the login page; pass the Invoice page as the redirect_to query arg.
13
+
if ( ! is_user_logged_in() ) {
14
+
if ( ! empty( $invoice_code ) ) {
15
+
$invoice_url = add_query_arg( 'invoice', $invoice_code, pmpro_url( 'invoice' ) );
16
+
} else {
17
+
$invoice_url = pmpro_url( 'invoice' );
18
+
}
19
+
wp_redirect( add_query_arg( 'redirect_to', urlencode( $invoice_url ), wp_login_url() ) );
20
+
exit;
21
+
}
22
+
23
+
if ( ! empty( $invoice_code ) ) {
24
+
$pmpro_invoice = new MemberOrder( $invoice_code );
25
+
26
+
if ( ! $pmpro_invoice->id ) {
27
+
// Redirect user to the account page if no invoice found.
28
+
wp_redirect( pmpro_url( 'account' ) );
29
+
exit;
30
+
}
31
+
32
+
// Make sure they have permission to view this.
33
+
if ( ! current_user_can( 'pmpro_orders' ) && $current_user->ID != $pmpro_invoice->user_id ) {
34
+
wp_redirect( pmpro_url( 'account' ) ); //no permission
35
+
exit;
36
+
}
37
+
}
38
+