I'm trying to hook into WordPress publish. The code below is what I'm using, but it doesn't appear to be running. I have it in a plugin file that I deactivate/reactivate each time I make changes (not sure if that's necessary to do that though). Post type is "auction".
add_action( 'publish_auction', 'bvf_set_ceiling_once_on_first_publish' );
function bvf_set_ceiling_once_on_first_publish( $post ) {
$post_id = $post->ID;
if ( !get_post_meta( $post_id, 'ceiling', $single = true ) ) {
$reserve = get_post_meta( $post_id, 'reserve', $single = true );
$ceiling = $reserve * (rand(40,60) / 100);
update_post_meta( $post_id, 'ceiling', $ceiling );
}
}
Now I'm trying the following (01/16/13):
<?php
/**
* @package Bids_Views
* @version 0.0.1
*/
/*
Plugin Name: Bids/Views
Description: None
Author: Jerry T.
Version: 0.0.1
*/
add_action('publish_post', 'bvf_set_ceiling');
function bvf_set_ceiling( $post_id ) {
$post = get_post($post_id);
$reserve = get_post_meta( $post_id, 'reserve', true );
$ceiling = $reserve * (rand(40,60) / 100);
update_post_meta( $post_id, 'ceiling', $ceiling );
}
?>