Support Forum
Support › MB Revision › Custom fields exist already...
I have just purchased the MB Revision plugin as I would like to track revisions to the posts contained within an existing Custom Post Type. The fields exist already (they were created using the WP Types plugin) and all I am wanting to do is track revisions.
Can someone please give me an idea of the syntax required to add existing CPT to the metabox code in functions.php? The only code I can find is to create new CPT...
Thank you
Bonnie
Can anyone help please?
Hi Bonnie,
The syntax to add fields to existing custom post type is nothing different from new custom post type. In the meta box settings, just add 'post_types' => array( 'your_post_type' )
. Please check this docs for more info.
Please note that if the fields already exist, then there's no way to track their previous values. The extension can track values from now on.
Hi Anh.
Unfortunately that link is broken - do you have the correct link please?
Thank you
I've found another page with documentation. I still can't work it out, though.
When I add an existing field, it brings it up as an additional meta box below my existing custom fields. What I want to do is track the changes made to those existing custom fields, not store new values in new boxes at the bottom. I am a little bit confused...
I've just fixed the docs link. There was a problem with my HTTPS setup.
Just curious, how do you create custom fields? Do you create with the WP-Types plugin?
Thank you for fixing the link!
Yes, they have been created with WP-Types. So they already appear on the post type - I don't want to add them again, if that makes sense. I just want to track their changes.
To give it a bit of context, I maintain the website for a large hospital with a number of laboratories. I have a custom post type called "Lab Tests".
This has the following fields, all created in WP-Types:
Sample Unit (e.g. mL)
Sample Size (e.g. 40)
Sample Type (e.g. Blood, Urine, etc.)
Special Timings (e.g. must be tested within 48 hours)
Patient Preparation (e.g. Patient must refrain from vigorous physical activity for 48 hours beforehand.)
I want to make sure that if any of the above values is changed, that change is tracked as a revision - and it shows the revisions screen like it does for regular pages (which use the editor) e.g. clearly showing that Sample Size has been changed from 40 to 50.
Does this make sense?
Thank you.
Hi Bonnie,
Thanks for the info. That helps a lot understanding your situation.
In this case, I’m afraid to tell you that the MB Revision only works with custom fields made by Meta Box, not made by other plugins such as WP-Types. So my suggestion is you can rewrite the code to transform fields created by WP-Types to Meta Box. If the number of fields are not large and fields are not complicated, I think you can do that simply by following the instruction in the link I posted in the previous reply.
However, that depends on how WP-Types saves data in the database. If it’s compatible with the default WordPress behavior of storing post meta, then the transformation will be easy. This is how Meta Box saves data in the database.
Oh no! I didn't realise when I bought it. I don't think I have the technical knowledge to do that... yes, I believe WP-Types metadata is created in the exact same way, from what I have read online. However I wouldn't have a clue how to rewrite the code...
Can you send me an account admin via the Contact page? I can look at that for you.
Hi Anh
Yes, no problem.
Thank you.
Bonnie