I have two identical post types (say) 'import' & 'data', 'import' is for importing to 'data'
I'm using a plug-in to read a CSV into 'import', I wish to use toolset views and a PHP snippet to transform 'import' fields into 'data'
I assume the best way would be a View to loop through 'import' with a nested View finding posts in 'data' (via a common field)
Ive used the following sort of code in the past, which I would call from the nested view:
-----
$post_ID = get_the_ID();
$this_post_address = get_post_meta($post_ID,'wpcf-user-address', true);
....some code
update_post_meta( $post_ID, 'wpcf-range', $a );
-----
which I've used to manipulate a post of one type (ie the 'data' above)
my question is: how do I access (read) the 'import' posts from within the snippet?
perhaps you can point me at existing examples in the documentation
Thanks for your great support
Hello,
Toolset Views/Blocks plugins are for displaying data, it is not a good idea to use them to import data.
If you just need to change "import" post into 'data' post, you can setup a post form for editing "import" post, after user submit the form, use action hook "cred_save_data" to trigger a PHP function, in this PHP function, change the current "import" post's post type into "data", more help:
https://toolset.com/documentation/programmer-reference/cred-api/#cred_save_data
https://developer.wordpress.org/reference/functions/wp_update_post/
For post type parameter of function wp_update_post(), see the document:
https://developer.wordpress.org/reference/functions/wp_insert_post/
'post_type'
(string) The post type. Default 'post'.