Title: Missing arguments for action/filters
Last modified: September 1, 2016

---

# Missing arguments for action/filters

 *  Resolved [nickbreen](https://wordpress.org/support/users/nickbreen/)
 * (@nickbreen)
 * [10 years, 1 month ago](https://wordpress.org/support/topic/missing-arguments-for-actionfilters/)
 * Getting the following errors for (at least) these actions:
    - wpo_wcpdf_after_order_data
    - wpo_wcpdf_before_item_meta
 * `
    Warning: Missing argument 2 for {closure}() in /var/www/wp-content/plugins/
   wordpressplugin-woocommerce-purchaseorder/plugin.php on line 92
 * `
    Missing argument 2 for {closure}() in /var/www/wpcontent/plugins/wordpress-
   plugin-woocommerce-purchaseorder/plugin.php on line 102
 * `
    Warning: Missing argument 3 for {closure}() in /var/www/wp-content/plugins/
   wordpress-pluginwoocommerce-purchase-order/plugin.php on line 102
 * Relevant sections of `plugin.php`:
 * `
    // See http://docs.wpovernight.com/woocommerce-pdf-invoices-packing-slips/
   pdf-template-action-hooks/ add_action('wpo_wcpdf_after_order_data', function (
   $template_type, $order) use ($fields) { foreach ($fields as $field => $def) if(
   $value = get_post_meta($order->id, $field, TRUE)) printf('<tr><th>%s:</th><td
   >%s<td/></tr>', esc_html($def['label']), esc_html($value)); });   add_action('
   wpo_wcpdf_before_item_meta', function ($template_type, $item, $order) { echo "
   <span class=\"item-meta\">{$item['single_price']}</span>"; });
 * Other details:
 * WP installation is multi-site.
    WooCommerce PDF Invoices & Packing Slips: Version
   1.5.34 WooCommerce: Version 2.6.2
 * [https://wordpress.org/plugins/woocommerce-pdf-invoices-packing-slips/](https://wordpress.org/plugins/woocommerce-pdf-invoices-packing-slips/)

Viewing 2 replies - 1 through 2 (of 2 total)

 *  Thread Starter [nickbreen](https://wordpress.org/support/users/nickbreen/)
 * (@nickbreen)
 * [10 years, 1 month ago](https://wordpress.org/support/topic/missing-arguments-for-actionfilters/#post-7544504)
 * This is using the `Simple` template, unaltered.
 * I hacked around this experimentally after inspecting the `Simple/invoice.php`
   and using `global $wpo_wcpdf;` and referencing `$wpo_wcpdf->export->order` directly
   in the `wpo_wcpdf_before_order_details` action function.
 * This of course doesn’t work for `item` in the `wpo_wcpdf_after_item_meta` action.
 * … some time passes, and I actually read [https://developer.wordpress.org/reference/functions/add_action/](https://developer.wordpress.org/reference/functions/add_action/)
   and realise that I’m Just Doing It Wrong as I’m missing the `$accepted_args` 
   argument.
 *     ```
       add_action('wpo_wcpdf_before_item_meta', function ($template_type, $item, $order) {
         echo "<span class=\"item-meta\">{$item['single_price']}</span>";
       }, 10, 3);
       ```
   
 *  Plugin Contributor [Ewout](https://wordpress.org/support/users/pomegranate/)
 * (@pomegranate)
 * [10 years, 1 month ago](https://wordpress.org/support/topic/missing-arguments-for-actionfilters/#post-7544524)
 * Hi! Contact the devs of the “wordpress-plugin-woocommerce-purchaseorder” plugin–
   their use of add_action (which requires Closures = PHP 5.3+) is probably not 
   compatible with your PHP version.
 * This would be the standard format (although I would not recommend using globals
   like that, this is the easiest translation):
 *     ```
       add_action('wpo_wcpdf_after_order_data', 10, 2);
       function wpo_wcpdf_after_order_data ($template_type, $order) {
       	global $fields;
       	foreach ($fields as $field => $def) {
       		if ($value = get_post_meta($order->id, $field, TRUE)) {
       			printf('<tr><th>%s:</th><td>%s<td/></tr>', esc_html($def['label']), esc_html($value));
       		}
       	}
       }
       ```
   
 * And yes, you always need the `$accepted_args`.
 * Hope that helps!
    Ewout

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Missing arguments for action/filters’ is closed to new replies.

 * ![](https://ps.w.org/woocommerce-pdf-invoices-packing-slips/assets/icon-256x256.
   png?rev=2189942)
 * [PDF Invoices & Packing Slips for WooCommerce](https://wordpress.org/plugins/woocommerce-pdf-invoices-packing-slips/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/woocommerce-pdf-invoices-packing-slips/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/woocommerce-pdf-invoices-packing-slips/)
 * [Active Topics](https://wordpress.org/support/plugin/woocommerce-pdf-invoices-packing-slips/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/woocommerce-pdf-invoices-packing-slips/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/woocommerce-pdf-invoices-packing-slips/reviews/)

 * 2 replies
 * 2 participants
 * Last reply from: [Ewout](https://wordpress.org/support/users/pomegranate/)
 * Last activity: [10 years, 1 month ago](https://wordpress.org/support/topic/missing-arguments-for-actionfilters/#post-7544524)
 * Status: resolved