Here’s a solution that take’s advantage of Rilwis’ action hook… so you can profit from his nonce checking without needing to add your own.
add_action('rwmb_after_save_post', 'post_updated');
function post_updated($post_id) {
// verify post is not a revision & not an autosave
if (!wp_is_post_revision($post_id) && !(defined('DOING_AUTOSAVE') && DOING_AUTOSAVE)) {
global $prefix;
$prefix . 'name';
// check that the custom field is being POSTED
if( isset( $_POST[$prefix . 'name'] ) ){
$my_post = array();
$my_post['ID'] = $post_id;
$my_post['post_title'] = sanitize_title( $_POST[$prefix . 'name'] );
// Update the post into the database
wp_update_post( $my_post );
}
}
}
To limit this function to only run for a specific metabox, you could use this add_action
instead:
add_action("rwmb_{$meta_box['id']}_after_save_post", 'post_updated');
Without seeing your metabox definitions, I don’t know what to change the ID to, so you will have to do that.
NB: Untested, but I think it is close. Please see wp_update_post()
in the codex for how that function works.