GLOBAL Array gets deleted… – WP All Import function.php –

actually I’m writing an additional code for the Functions Editor for the WP All Import Plugin. This additional code is supposed to move some datas… Nothing special…

Anyway. My problem is, that my $GLOBALS["productsXML"] array gets flushed every time the WP All Import is loading a new function.

Here is my code:

add_action('pmxi_before_xml_import', 'wp_all_import_before_xml_import', 10, 1);
add_action('pmxi_saved_post', 'my_saved_post', 10, 2);

$GLOBALS["productsXML"] = array();

function wp_all_import_before_xml_import($import_id){ ... }
function my_saved_post($pid, $xml_node){ ... }

As you can see, I add the functions and then I’m initializing the $GLOBALS["productsXML"] Array. The plugin works like this:

  • Call the wp_all_import_before_xml_import function at the beginn of the entire import. (Here I load values in the $GLOBALS["productsXML"] Array)
  • Call the my_saved_post function every time a post gets saved (Here I want to access on the $GLOBALS["productsXML"] Array -> But it is empty…)

Does anyone knows, why my array gets flushed if the plugin is calling another function? – I mean, I initialized the array Global, because I need to transfer values!!!

How can I change that again. I created a log. Here you can see, that the array is loaded in the wp_all_import_before_xml_import function but in the my_saved_post function it got flushed…

I do not even have the possibility to flush the array by my self because I print the array to the log at the beginning of the function… So it must be flushed by the script/plugin itself…

Does anybody knows why my array gets flushed and how I can prevent that?

Greetings and Thank You!

Read more here: GLOBAL Array gets deleted… – WP All Import function.php –

Leave a Reply

Your email address will not be published. Required fields are marked *