I am adding few meta fields for product post type using wp_insert_postaction and it is working perfectly.

But I have to trigger my function upon product imports as well as this action is not firing on products import. Products are imported directly in database so Is there any way to trigger this function upon import. I will really appreciate your help.

  • 1
    To clarify, you want your function to fire when using the WordPress Importer or is there another method in-use for importing posts?
    – jdm2112
    May 16 '19 at 18:42

If you are trying to fire your function when the WordPress Importer runs, there are a few filters and action hooks available.

From the plugin documentation:

import_start: occurs after the export file has been uploaded and author import settings have been chosen

import_end: called after the last output from the importer


  • But the products are imported directly in database. So these above mention filters will not work in my case.
    – wplearner
    May 16 '19 at 18:53
  • How are the products being imported?
    – jdm2112
    May 16 '19 at 18:59
  • From Netsuite to directly in database of my website
    – wplearner
    May 16 '19 at 19:00
  • Then WordPress does not know about this activity at all. It is happening outside of WordPress execution. You will need to setup a cron job to cycle regularly or manually trigger the code after you complete an import. Perhaps you could create a MySQL trigger dev.mysql.com/doc/refman/5.7/en/trigger-syntax.html
    – jdm2112
    May 16 '19 at 19:06
  • Thank you for your suggestion. I will implement cron job for this.
    – wplearner
    May 16 '19 at 19:07

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.