Action hooks!
http://wiki.wordpress.org/Plugin/API
I think
add_action('publish_post', 'my_function');
is what you want. I believe there is a bug that trips this when a post is published AND edited… I might be wrong, so you could also try
add_action('edit_post', 'my_function');
. Using both wouldn’t hurt. 🙂
Thread Starter
Anonymous
OK, so I’ve created the plugin, made a function, and declared add_action on publish_post — how do I access the post title and post body in the function?
(By the way, what I’m trying to do is convert a few windows-1252 characters that frequently show up on our blog — such as em-dash and smart quotes — into UTF-8.)
This seems to be the only post that comes close to what I want to do, but frankly I dont’ get it! :\
What I want to do is simply change bad words to asterisks or otherwise blot them out in ALL posts — or moderate posts that have them.
I want to create an open forum where anyone can post (not just comment), but the filters built into WP are only on comments, not posts.
I have downloaded Dougal’s pirate filter (so very cool! :)), but it seems to only work on a per-post basis (or at least, that is all the instructions explain). I want something for all posts. I like the moderation fucntion on comments in WP, but is there a way to apply it to posts?
Marci 🙂
I have downloaded Dougal’s pirate filter (so very cool! :)), but it seems to only work on a per-post basis
It means that you could disable/enable for each individual post, instead of automatically applied to all posts.
There’s also another plugin
http://www.coffee2code.com/archives/2004/06/29/plugin-text-replace/
PERFECT! Thanks for the link to Scott Riley’s plugin. It’s just what I needed for really simple post filtering. In fact, I even added a bit to it with an extra filter on the post title:
‘add_filter(‘the_title’, ‘c2c_text_replace’, 2);’
I’m sure the pirate filter would have worked great too, and maybe now that I have more of a clue how this works, I can still use it. Or just enjoy a pirate-y day every september. 🙂
Thanks again!!!
Any comments about add_filter(‘the_posts’, ‘my_functions’);
?