Hello,
on the save action on Post RelationShip metabox, i would like to automatically fill a field with a value of 2 concatenating fields and get this value shows up on after the Ajax Refresh.
example:
Data: Custom Field 1 (having a value), Custom Field 2(having a value) , Custom Field 3( empty and readonly).
by hitting save ==> Custom Field 3 will be populated by Custom Field1 + Custom Field 2
i have tried the following codes " a minimal one to explain the simple result" but the value is not inserted on the Database
add_action('post_updated', 'add_new_match', 10, 2);
function add_new_match($post_id,$post_data) {
/*add_post_meta also tested */ update_post_meta($post_id, 'wpcf-my-custom-field','new Value',false);
}
or : add_action( 'pr_save_child_post', 'add_new_match', 99, 4 );
function add_new_match($post_id,$post_data) {
/*add_post_meta also tested */ update_post_meta($post_id, 'wpcf-my-custom-field','new Value',false);
}
or : add_action( 'updated_post_meta', 'add_new_match', 99, 4 );
By a debug and some dummy data i can get it updated if i'm hitting save on a different record with a specific $post_id passed on the update_post_meta function :
I hit save on record id 3046 and passing the post_id value 3045
add_action('post_updated', 'add_new_match', 10, 2);
function add_new_match($post_id,$post_data) {
/*add_post_metaalso */ update_post_meta(3045, 'wpcf-my-custom-field', 'new Value', false);
}
the save button have this function: mysite.com/admin-ajax.php?action=wpcf_ajax&wpcf_action=pr_save_child_post&post_type_parent=my-post-type&post_id=3047&parent_id=2899&post_type_child=child-post&_wpnonce=4b422bd202
if you can please help to get it through.
thank you