I want to trigger my own custom function (that includes sending an email message) after someone posts in the forum. When I use the “sph_post_create” action as a trigger, I get one email message (like I want to), but the $spVars variable doesn’t contain the data about the post that I want. If I use the sph_after_post action, $spVars contains the data I want about the post, but then my function triggers multiple times for some reason, which I don’t want. Any idea how I can get the $spVars data I want but only have it triggered once? Thanks.
I also tried the sph_new_forum_post action, and $spVars again didn’t contain the post’s data.
I would recommend the ‘sph_new_post’ action which has one argument which is the $newpost array which should have everything you need defined. And this is triggered at the post creation time after success of saving has been accomplished,
It took me a while to figure out how to be able to use $newpost. It turns out I had to add two more arguments (the 10 & 1) in my add_action declaration: add_action( ‘sph_new_post’, ‘my_function’, 10, 1 ) …where the 1 refers to the one argument being passed to my_function via my_function($newpost). Thanks.