Plugin Development: Wordpress processes twice on post update. How to skip process on the first?

Exit just a moment. 0 answers, 0 views
plugins plugin-development wp-admin

When you create a plugin and set up a process function, Wordpress will run the plugin process function twice upon clicking the update button. I believe the first process is for the versioning (revision) post, and the second the actual post.

Now, I've got an INSERT function in my process, so it is now inserting the data twice.

What is the best way to ensure that processing doesn't happen while creating the revision and and only on the actual post processing?

* Note: Targeting Wordpress 3.0+ *

An Example (complete plugin):

Plugin Name: Something Amazing
Plugin URI:
Description: Displays something.
Author: Some guy
Version: 1.0
Author URI:
function call_something() {
 return new something();
if (is_admin()) add_action('load-post.php','call_something');

class something {

 public function __construct() {

 public function something_add_boxes() {
  add_meta_box('something','Some Thing',array(&$this,'something_form'),'post','side','default');

 public function something_form($post,$args) {
  echo '<p><input type="text" name="somethingnew" /></p>';

 public function something_process($id) {
  echo 'hey there! I\'m going to cause a redirect warning, but you will see this line twice per submit!';

Perhaps there is a better hook to use to process that doesn't make it write twice?

No Answers Yet


Popular Tags