Return code from save_post action?

Actions should not return anything, and action hooks are not built to do anything with a returned value. (That is what filters are for.)

If you look at the source for that particular hook, you can see that even if you return something nothing happens. Whatever you return isn’t captured. It vanishes from the code.

The sample code you found is in my opinion sloppy and confusing. I assume that the point of the return $post_id lines is just to kill the script, which it would do, but all that is really necessary to kill the script is a simple return;. Even a return false; would be less confusing.

Leave a Comment