Skip to content

Instantly share code, notes, and snippets.

@RiFi2k
Created April 3, 2020 16:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RiFi2k/30788e9c2c3d664c1fe37862dea80de5 to your computer and use it in GitHub Desktop.
Save RiFi2k/30788e9c2c3d664c1fe37862dea80de5 to your computer and use it in GitHub Desktop.
if ( class_exists( 'woocommerce' ) ) {
if ( is_wc_endpoint_url( 'order-pay' ) ) {
global $wp;
$order_id = $wp->query_vars['order-pay'];
$order_author_id = get_post_field( 'post_author', $order_id );
$current_user_id = get_current_user_id();
if ( $order_author_id !== $current_user_id ) {
// Do something here when user did not place the order.
// Redirect to homepage etc.
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment