Closed mmw562 closed 3 years ago
Hi @mmw562, getting post meta is possible. How your post meta is configured or created? You can attach a snapshot if you have any.
For general purposes, the post is synced with all data.
One way to save post meta / or exclude certain fields is to use the plugin's filter hook.
https://firebase-wordpress-docs.readthedocs.io/en/latest/hooks/filters.html
Together with save_post
hook from WordPress (https://developer.wordpress.org/reference/hooks/save_post/).
The post is created using a form. The form software is called formidable. I have attached an image of how it is entered. The form itself creates a post and saves the meta data as I dictate in the form settings.
For custom metadata fields, you may need to do the following as I mentioned above. Do you have a developer that can help with it?
I may be able to handle this. Do you, by chance, have an example or docs for this filter? Specifically, the $doc_id is confusing to me. What is that referring to? Is it the post id?
It's a term in firestore for document id.
/**
* Send Data to Firebase Database
*
* @param [type] $database_type realtime | firestore
* @param [type] $collection_name
* @param [type] $doc_id
* @param [type] $data object
* @return boolean
*/
// start saving data to firebase
apply_filters('firebase_save_data_to_database', $database_type, $collection_name, $doc_id, $data);
Example if you have $collection_name = 'users', and the $doc_id = '1', then your data will be saved to realtime / firestore under the path /users/1.
Hope this helps.
Tremendous help! Thank you Dale. I was able to get it working after a fair bit of testing.
Is there, by chance, a hook to update the information in the database?
I'm happy to hear that! You can use the same hook to update data in firebase. It's the upsert function.
Hello Dale!
I was super excited about the feature to bring in the post data - its EXACTLY what I needed. The post did sync, but unfortunately, NONE of the post meta came with it - which was everything I needed. Is this something I'm doing wrong?
As an addition note, so much information came across that I didn't need. Is there any way to exclude certain fields?