In this view I also have another column called 'comprobante' (it is the possibility of attaching a file) and 'estado'.
I want to be able to relate these three fields:
when the 'comprobante' is uploaded and the 'comercio' assigned, the status must change from unused to used
Hello,
I have checked your previous thread:
https://toolset.com/forums/topic/view-with-relationship/#post-1855885
The credentials you provided was removed to protect your privacy.
Please provide your website credentials in below private message box, also elaborate the question with more details:
When and how do you want to relate those three fields?
How and where do you setup those three fields? custom field or taxonomies?
Thanks
Thank you Luo
I can't include the credentials
In the view 'lista administrator bonos'
wp-admin / admin.php? page = views-editor & view_id = 6275
/listado-bonos-administrador/
I have the 'comprobante' column (to upload a file), the 'comercio' column to assign a 'comercio' and the 'estado' column.
In 'estado' I have 3 status:
- no usado (it is the one that comes out by default when I create the coupon)
- caducado (this status should be entered when the bonus expiration date has passed)
- usado
I need to do the conditional so that, when the expiration date of the coupon passes, it is marked as expired and when I add the 'comprobante' and assign the 'comercio', the coupon changes status to used.
I have enabled the private message box, please provide your website credentials in it, thanks
I can login your website, but your website isn't in English, it is hard to locate the fields.
Please elaborate the question with more details:
when the expiration date of the coupon passes, it is marked as expired and when I add the 'comprobante' and assign the 'comercio', the coupon changes status to used.
Which one is the "the expiration date of the coupon"? is it custom date field "Fecha de creación del bono"?
Which one is the "coupon status"? is it "estado" taxonomy?
Are you going to compare the custom date field "Fecha de creación del bono" value with current time value?
If it is lower than current time value, then update the "estado" taxonomy value as "caducado"?
When and where are you going to trigger above action? are you going to trigger it automatically?
If it is, there isn't such kind of built-in feature within Toolset plugins, you will need to consider custom codes, for example.
1) Use WP action hook to create CRON job, and trigger a custom PHP function
https://developer.wordpress.org/plugins/cron/
2) In this PHP function, get all "coupon" posts, which "expiration date" is lower than current time, and "coupon status" is "no usado":
https://developer.wordpress.org/reference/classes/wp_query/
And update each post, setup "coupon status" value to "caducado"
https://developer.wordpress.org/reference/functions/wp_set_post_terms/
For your reference.
Hi Luo,
Thanks for you reply,
Which one is the "the expiration date of the coupon"? is it 'Fecha de caducidad'
Which one is the "coupon status"? is it "estado" taxonomy? Yes, it is
Are you going to compare the custom date field "Fecha de creación del bono" value with current time value? I need to compare 'Fecha de caducidad' with current time value
If it is lower than current time value, then update the "estado" taxonomy value as "caducado"? Yes, it's ok
It's current time is more than 'fecha de caducidad', status 'bono' may be 'caducado' (expired)
When and where are you going to trigger above actions? are you going to trigger it automatically?
If it is, you will need to consider WP CRON job, see my above answer:
https://toolset.com/forums/topic/change-post-taxonomy-when-image-field-is-uploaded-and-child-post-is-related/#post-1867619
Hi Luo!
I need it to be displayed in the 'administrator bonuses list' view but I understand that it will have to be registered in the backend. Can you help me with this code?
Hi,
Luo is on vacation, so I'll be following up on this ticket.
Reading through the requirements that you've shared, I understand that you'd like to automatically change the "Estados" taxonomy term attached to the "Bonos" posts, based on the current time and the "Fecha de caducidad" custom field value.
If that is correct, you'll need a CRON job, that is set to run a custom function periodically ( for example, once or twice a day ) to cycle through all the "Bonos" posts and then change the "Estados" taxonomy term, accordingly.
Since there is no built-in feature available in Toolset plugins for this, you'll need to write a custom function for this. As much as we would like to help, customization like this is beyond the scope of support that we can provide over the forum ( ref: https://toolset.com/toolset-support-policy/ ). But we do our best to guide in the right direction, whenever possible.
To learn about how to set a Cron job in WordPress, here are some useful resources:
hidden link
hidden link
The "wp_set_post_terms" function from WordPress can be used to programmatically add/update the attached taxonomy term:
https://developer.wordpress.org/reference/functions/wp_set_post_terms/
For more personalized assistance around custom code, you can also consider hiring a professional from our list of recommended contractors:
https://toolset.com/contractors/
If you're open to alternatives, you can also consider using the post expiration feature, to automatically change the status of the "Bonos" posts, after the set time:
https://toolset.com/course-lesson/setting-up-automatic-post-expiration/
This way you'll no longer need the "Estados" taxonomy or the "Fecha de caducidad" field.
regards,
Waqar