Question

I have this filter:

$post_arr = apply_filters('insert_product_post_data', $post_arr, $data);
add_filter('insert_product_post_data', 'my_filter', 10, 2);
function my_filter($post_arr, $data) {
    //change $data here
    return $post_arr;
}

I need to change the value of $data is any way to do this ?

Was it helpful?

Solution

No this isn't possible without changing the original code. Filters work on the very first parameter, the other parameters are provided for context.

You will need too either get the author to add a filter for the data variable, fork the plugin, or use a competitor.

The only exception, is if $data is an object not an array and you want to modify it. However, it cannot be replaced, and it cannot be done with an array or any other data type.

Licensed under: CC-BY-SA with attribution
Not affiliated with wordpress.stackexchange
scroll top