I am using WooCommerce Print Invoice plugin to print invoices. Now I am working on a Cordova app for my website and I need to be able to see invoices from wordpress.

Plugin has a function to hide or redirect page if you are not logged in.

public function print_document_action() {

        // listen for 'print' action query string
        if (isset($_GET['wc_pip_document'], $_GET['wc_pip_action']) && 'print' === $_GET['wc_pip_action']) {

            // sanity check, if user is not logged in, prompt to log in
            if (!is_user_logged_in()) {

            $nonce = isset($_REQUEST['_wpnonce']) ? $_REQUEST['_wpnonce'] : '';

            // security admin/frontend checks
            if (!$nonce || !wp_verify_nonce($nonce, 'wc_pip_document')) {
                die(__('You are not allowed to view this page.', 'woocommerce-pip'));

Can this be overwritten from functions.php?

Tried to use entire function again, without those lines like this:

add_filter('print_document_action', 'showInvoices', $priority = 9999, $args = 1);
function showInvoices() {
    // same function without sanity check and security admin/frontend checks

Tried also to generate nounce with JSON API plugin and run page like this:


This also is not working. Any ideas?


Try to remove the plugin function from the filter.

Are you sure the plugin function and the filter have the same name!

*You will need to know the priority that the plugin function is using to use it in remove_filter, I will assume It's the default (10).

remove_filter( 'print_document_action', 'print_document_action', 10 );

Then add your function to the filter.

add_filter('print_document_action', 'showInvoices', $priority = 9999, $args = 1);
  • it's not working, tried with different priority values too – Adrian Sep 28 '18 at 13:19
  • You must use the same priority value that plugin function is using. – Ash0ur Sep 28 '18 at 15:31
  • yes, but I don't know what is it. How can I find it? – Adrian Oct 3 '18 at 8:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.