How to do_action and get a return value?

The cool thing is a filter is the same as an action, only it returns a value, so just set it up as a filter instead:

add_filter( 'myplugin_clean_logs', array( 'MyPlugin_Logs', 'clean_logs' ) );

Then something like:

$affected_rows="";
$affected_rows = apply_filters( 'myplugin_clean_logs', $affected_rows );

should pass $affected_rows to clean_logs() (and whatever other functions you may have hooked to myplugin_clean_logs) and assign the return value back to $affected_rows.

Leave a Comment

tech