Hi guys, on my pet project again.
I have a CRED form for editing a product. I included this:
[cred_delete_post_link class='pad-t-1 btn cred-refresh-after-delete' text='Изтриване' message='Сигурни ли сте, че искате да изтриете този продукт?' message_show='1' action='trash']
To delete the product.
Works fine, however the product images which I uploaded remained on my server.
Is this normal? Do I need any extra code to delete the attachments?
Yes, that is expected.
The Attachments in WordPress might be used in several other places, and deleting a post does never delete an attachment too.
If you need to delete those attachments on post deletion, you need to hook into the CRED Form submit action with cred_save_data, and get the Attachment so to delete it.
https://toolset.com/documentation/programmer-reference/cred-api/#cred_save_data
I do not suggest to do it. It might be that you will miss images elsewhere after.
Well, I am building a platform where farmers can upload products/with photos/.
So I need a method to clean up the data after deleting a product.
These images are only being uploaded by farmers and tied only their products.
What would be the most appropriate way to achieve this?
I am looking into the link you provided, let me know if I need something extra.
I'll also ask more if I need further help.
I have already setup my products as a custom post type.
These products are ONLY being created by and edited by CRED forms from the Farmer's admin area.
Is the image a Custom Field made with Types?
Then you can access it's URL by get_post_meta($post_id, 'your-wpcf-field', true) and with this, you can get the ID of the Image:
hidden link
Then, you run wp_delete_post($image_id) to remove the images.
https://codex.wordpress.org/Function_Reference/wp_delete_post
Yes, that is correct.
I am going to try this now. Thanks
Please let me know if this worked for you.
Beda, can you please check how the support cleanup robot settings are set up?
This is not the first time I am being pushed to resolve a problem on my pet project (I usually work on weekends on this one, or as time allows.) I am being told that threads stay open for 30 days but it seems the bot thinks differently.
I am coming back to this one soon and I don't want to open a new thread, or having to come back and just write some mumbo-jumbo to fool the bot every now and then.
Here's a screenshot.
Clearly the Bot will not wait a month.
I think, if I recall right, it's a week for Bugs, and a little more for How To Questions.
I will get clear data about this from our own system admins, but they are back online Monday, and me, I am back Tuesday.
So, I can firstly post this information here Tuesday.
For this purpose I will keep the Ticket in status "I am still working on this".
So, this is how it should work.
It depends on what I (supporter) sets as the ticket status when we reply to you (the user).
>I think it's resolved
If the user has not replied for 3 days now, we send a notification to you.
The message should inform you that the ticket will be closed in 1 week.
Then you will receive an email once the ticket is closed.
>I need more info from the user
If the user has not replied for one week now, we send a notification to you.
The message should inform you that the ticket will closed in one week.
As well you are notified when it's closed.
>All escalated ticket status (e.g. escalated to second tier, escalated to developers)
In any case, if the ticket is older than 2 weeks we send a notification to the assigned supporter.
This tickets are not be closed automatically.
>Fixed in next release
In any case, if the ticket is older than 3 weeks we send a notification to the assigned supporter.
This ticket is not be closed automatically.
Looking at our ticket history here and your email I see no mention of 30 days.
Can you elaborate where you saw the 30 days mentioned?
It might be a leftover from the old support that we did forget to update.
Also if you have inputs to the process please let me know.
I unterstand you work from weekend to weekend, making the 3 days step a but narrow.
For example this ticket now, I set it to "I need more info from the user" since I need more details from you.
The Robot should nag you in 7 days from now, if there is no new reply, giving you 7 more days to reply, hence, 14 days totally.