Support Forum
Support › MB Custom Table › Gravity Form Advanced Post Creation and MB Custom Table
Hi Metabox,
I want to use Metabox Custom Table to store custom post type data It works when I directly create the post from custom post type admin page In another hand, Im using Gravity Forms Post Creation to create that custom post type with custom field linked. It works when I turn off the custom table feature of that post type, all post metas are created normally. But when I turn on the custom table feature, the custom post has been created but all the custom field empty, no post row hasn't been created in the custom table (MySQL). I tried to install 2 scripts at : https://metabox.io/move-custom-fields-data-to-custom-tables, in order to move the data from post_meta to custom table. It runs well, now the data are copied from post_meta to custom table (but manually when I run the script from URL). A small problem is: the 1st time I run the script, it moved 1 record; the 2nd time => 2 records and so on... but what happen if I would have 100000 records? It cant clear the moved data, and process again the whole posts in that kind of post type.
So, is it possible to create custom post from GF post creation plugin (and other 3rd post creation plugin) that automatically store data In metabox custom table?
Thanks
Hi,
A small problem is: the 1st time I run the script, it moved 1 record; the 2nd time => 2 records and so on... but what happen if I would have 100000 records?
When you run the script, it will move all post meta of a post type from the table wp_postmeta to the custom table. Please read more here
https://metabox.io/move-custom-fields-data-to-custom-tables/#step-2-move-the-data-to-the-new-custom-table
So, is it possible to create custom post from GF post creation plugin (and other 3rd post creation plugin) that automatically store data In metabox custom table?
I think it is not possible. GF form only supports storing custom field values in the standard table of WordPress wp_postmeta
. You can contact GF form support to ask for help with this case.
I am trying to achieve a similar goal to the op. Gravity Support advise that they provide a hook for running additional functions after a post has been created and values have been saved to that table... gform_advancedpostcreation_post_after_creation
The form, feed, and entry data is also passed into that function.
In taking this path, can I ask - what would be the best approach to getting the data copied over into a custom table from Metabox?
Many Thanks in advance
I have submitted a ticket.
Hi,
With this hook, you can call the public API of MB Custom Table extension to add the field value to the custom table. For example:
add_action( 'gform_advancedpostcreation_post_after_creation', 'after_post_creation', 10, 4 );
function after_post_creation( $post_id, $feed, $entry, $form ){
$data = [
'field_1' => 'value 1',
'field_2' => 'value 2',
'field 3' => ['one', 'two', 'three'],
];
\MetaBox\CustomTable\API::add( $post_id, $table, $data );
}
Read more on the documentation https://docs.metabox.io/extensions/mb-custom-table/#api
https://docs.gravityforms.com/gform_advancedpostcreation_post_after_creation/