I'm using a template that uses the wp_insert_post() function to publish posts from outside the WordPress administrator. Now I'm creating a plugin to send an email to users when a new post is published (actually users who belong to a specific usergroup). From what I understand, I should use the wp_insert_post action hook so the plugin runs everytime a new post is inserted with that function, but somehow it's not working.
at the beginning of the plugin but it does not work. No error. It's just not being triggered.
When I try
and I publish a post from the WordPress administrator, plugin works fine and emails are sent. When using this, also plugin isn't triggered from outside the administrator.
Any idea on what could be wrong? Which action hook should I try too?
Thank you for your help.