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 ?
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
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.
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0