1

Possible Duplicate:
Adding submit or update button to custom metabox?

I added a Meta Box Like So:

add_action('add_meta_boxes', function() {
    add_meta_box('CNMeta', 'Custom MetaBox', 'CNCustomMeta', 'post');
});

I also added a thing that saves all of the meta information like this:

add_action('save_post', function($id) {
    if(isset($_POST['CNPrice']) ) {
        update_post_meta( $id, 'CNDetails', strip_tags($_POST['CNDetails']) );
    }
});

So they can save it by updating the post, it would be nice if I could add a submit button at the bottom of the meta box that also updates the post (and doesn't popup a warning saying "You are about to leave this post unsaved"

How would I do something like that?

3

1 Answer 1

1

To update a post.

<input id="publish" class="button-primary" type="submit" value="Update" accesskey="p" tabindex="5" name="save">
1
  • That's the first thing I tried actually. It's not a good solution because if the user makes changes to the post and then the user updates the custom meta box (a very common occurence) it will popup a warning message saying that they haven't saved their post.
    – Talon
    May 7, 2012 at 18:38

Not the answer you're looking for? Browse other questions tagged or ask your own question.