Hello, I am working on a registration form in Types where all information is completed in a custom post type called "player". I created a custom field called "unique-number". I want this "unique-number" to have the post-id as the default value when creating a new post. Can you please advise on how to do this?
Thanks!
Hi,
This is not supported natively by Types. you will need to add some custom code to do that.
you can use the save_post hook to override the field value.
To avoid confusions, Note that, if the field slug is test-field, it will be stored in the database like this wpcf-test-field
Example:
//This code is not tested, it's the client responsibility to test it on his own
function my_project_updated_send_email( $post_id ) {
$post_type = get_post_type($post_id);
if($post_type=='my_post_type')
{
update_post_meta( $psot_id, 'wpcf-test-field', $post_id);
}
}
add_action( 'save_post', 'my_project_updated_send_email' );
You cna use the previous code, modify it to make to work for your request.
Thanks.