Replies: 0
I have a site that allows admins to place orders on behalf of customers – a simple Point of Sale system.
I implemented the code to show a link to the pdf invoice on the checkout page as outlined in the FAQ but as the logged in user is different to the invoice customer user id, it shows an error.
Changing the code to allow any admin users to see the invoice gets past this limitation. Code snippet below:
// Check if current user is owner of order IMPORTANT!!!
if (!current_user_can('manage_options')) {
if ( $this->order->user_id != get_current_user_id() ) {
wp_die( __( 'You do not have sufficient permissions to access this page.', 'wpo_wcpdf' ) );
}
}
Basically it checks that the user not an admin, if not it checks if the id matches the invoice order.
I’d really appreciate if this patch was accepted into the main code.