Hi Anh,
Thank you for your info. I have tried what you said and it works, thank you for this.
Another question is:
What is the best way if you want to save customer info on the invoice edit page.
For example I am not only saving the customer of the invoice via metabox relationships, I am also saving the customer number as a seperate column in the invoice table. I do this because I need the customer number to build the invoice number.
Right now I am doing it like this:
I am hooking my function into save_post hook
add_action( 'save_post', 'insert_kundennummer', 10, 3);
I am looking if this saving is an auto-draft
if ( $post->post_status == 'auto-draft' ) { return; }
I am querying through the related posts, retrieve the post ID, get the custom meta field 'customer_number' and save it to the 'invoice_customernumber' field
$wpdb->update( $table_name, array( 'invoice_customernumber' => $inv_cust_no ), array('ID' => $post_id) );
Is this the best way to do this? Because I had some issues with WordPress auto-save feature I thought there is a better option to do this. Maybe you can help me. Thanks in advance!