I am writing a plugin that enables subscribed users to submit posts of a custom type, and I am trying to implement this feature via shortcodes. Now the problem is that instead of inserting one post, my code inserts hundreds of them, until PHP runs out of memory... Here is an ultraminimal code that reproduces the issue:
add_shortcode( 'occaz-ajouter', 'occasion_addedit' );
function occasion_addedit(){
wp_insert_post(array('post_title'=> 'hello',
'post_content'=> 'Hello everybody',
'post_author'=>1));
return "OK.";
}
(Of course, I have a page that contains the [occaz-ajouter] shortcode, and I encounter the problem when I visit this page.)
I saw that several people have encountered such infinite loops, but none of the solutions provided seems to solve my issue, since I use none of the hooks that usually explain the infinite loop... Any idea?
Thanks a lot,
Nown