Can you give me a better idea of what you should happen when a post is saved in relation to your own custom table in the database..
An exported row from that table plus an example of what a typical update does/changes would really help...
The $wpdb class has several functions you can use to update, insert or drop from the database..
Plugin code it's a case of..
add_action('save_post', 'myplugin_perform');
/* When a post or page is saved */
function myplugin_perform( $post_id ) {
global $wpdb;
// Verify if this is an auto save routine.
if ( defined('DOING_AUTOSAVE') && DOING_AUTOSAVE )
return $post_id;
// Check permissions
if ( 'page' == $_POST['post_type'] ) {
if ( !current_user_can( 'edit_page', $post_id ) )
return $post_id;
}
else {
if ( !current_user_can( 'edit_post', $post_id ) )
return $post_id;
}
// Do your own stuff here..
return;
}
Basic of basic examples...
Then look at some form of prepare -> update statement..
$wpdb->query( $wpdb->prepare("UPDATE $wpdb->tablename SET ( field1, field2 ) VALUES ( %d, %s )",$var_with_value1, $var_with_value2 WHERE x = y) );
I've not used the prepare method before, i but think the format above is correct, only examples i could find dealt with inserts... , you can use wp->get_results("SOME QUERY") if you find that easier..
In the above, %d tells the function this value is expected to be an integer, %s a string, then variables $var_with_value1, and $var_with_value2 are the variables holding data that go into the values, in matching order.. (works like sprintf).. field1 and field2 being the corresponding database columns/fields..
I've been playing with some code and managed to successfully update a row in another table each time a post is saved.... it's as simple as the above basic example...
If you only need this update to occur on the creation of new posts, and not after editting, then yes i think you might be able to hook onto the publish_post action instead..
Play around and see what works.. (you could proberly use the code in your theme's function file for what it's worth)...