I’m new to WordPress, and currently developing my first plugin and currently having difficulties.
How I can insert the add_filter action inside my submit function? I want the add_filter
action to process after the user click the submit button.
I have try this but it didn’t work.
if(isset($_POST['btn_submit'])) {
function addContent($content = '') {
$content .= "My content";
return $content;
}
add_filter('the_content', 'addContent');
}
Any help would be greatly appreciated. Thanks!
I think what you’re ACTUALLY looking to do is to
apply_filters()
.add_filter()
registers a new filter, whereasapply_filters()
does the filters that have been registered.If that’s not what you’re looking to do, then you need to be aware that
add_filter()
needs to be run every time you want the filter applied. This allows plugins to be removed without having to unregister all their filters and generally keeps a wordpress install pretty clean…it also helps with security. A better question might encompass a broader scope, where you state what you’re trying to do, rather than having us try and troubleshoot your implementation of it.You can also write in the following way:
@Shaon, Thanks for your reply. I couldn’t get that to work efefctively, but here is a very workable function I found:
http://core.trac.wordpress.org/ticket/15311#comment:13