Este hilo está resuelto. Aquí tiene una descripción del problema y la solución.
Problem:
I need to use this conditional output : define if the current user is author of a "subscription" post and if yes, if the subscription post date is between the "variable" custom fields start-date and end-date.
This support ticket is created hace 6 años, 7 meses. There's a good chance that you are reading advice that it now obsolete.
This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.
Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.
Hoy no hay técnicos de soporte disponibles en el foro Juego de herramientas. Siéntase libre de enviar sus tiques y les daremos trámite tan pronto como estemos disponibles en línea. Gracias por su comprensión.
I'm working on a new site and needs to use a conditional output based on this :
- I'm using a postype to define yearly variable => "variable". For that, I have created a "variable" post (let say ID=30) with some specific custom fields (start-date, end-date). This post will be updated each new year.
- Then, I have another postype to create subcriptions ("subscription"). That means, when user wants to subscribe, they validate a Cred form that is linked to the specific product. A new post "subcription" is created and assigned to the user as author with the postdate = creation date.
- Now, I need to use this conditional output : define if the current user is author of a "subscription" post and if yes, if the subscription post date is between the "variable" custom fields start-date and end-date.
Hello. Thank you for contacting the Toolset support.
Well - to check the current user is loggedin user - you can use [wpv-conditional] shortcode.
For example:
[wpv-conditional if="( '[wpv-current-user info="login"]' eq '[wpv-post-author format="meta" meta="user_login"]' ) "]
current user is same as the post author of current post.
[/wpv-conditional]
Thanks for taking care.
I'm not willing to detect if the user is connected or not (this is already done in another part of the page).
I want to detect if the connected user is the author of a post (postype : subcription) and if this post date is between two dates that are defined by the custom fields (start-date and end-date) of the post (postype : variable) and with id=30
So, conditional should be :
post (subcription) with author=connected user exists ? (there could be several post with the same author, but only one with the further date condition)
AND
post date (subscription) is between post (variable) start-date and post (variable) end-date (post (variable) id = 30)
When you say connected user post - do you mean logged in user is post author of post (subscription)? if yes:
I would like to know where exactly you want to add the condition in question - on subscription post?
The requested condition :
post (subcription) with author=connected user exists ? (there could be several post with the same author, but only one with the further date condition)
AND
post date (subscription) is between post (variable) start-date and post (variable) end-date (post (variable) id = 30)
Should be placed anywhere in the site, depending on thecontent that would be displayed for users having a vaild subscription and not for the others.
As you can see, the condition refers to 2 different posts of 2 different postypes ((subcription and variable)
Regards
Pat
Yes - I understand that - but for which post we need to run those 2 condition.
Because - we need to first make sure for which post we need to fetch the post author and it's parent post's custom date fields. Do you have structure ready for this - are you able to share test case example - if yes: I can write the condition for you but I need access details for that.
Not sure to understand. For me, this should be part of a conditional output, whatever the post / page where we are. This is just taking into account the current user and verify that this user is a post author of the postype "subscription" and that one of the found "subscription" posts is dated between 2 constants (that are recorded as custom fields of the post id=30 belonging to postype "variable").
Perhaps we can split into 2 :
- First, find the posts belonging to "subscription" havinf the current user as author
- Second, define is one of these posts date is between 2 variables
No sure that given you access to the site will help as nothing is alreading coded inthis area.
Regards
Pat
That's OK like this, but I wasstill having an issue with it.
I want to display the conditional output inside a product page layout. The aim of the conditional is to display a WC Cred that is linked to the product (by the field product_id).
As the Views in your proposal refers to another postype (subscription), I cannot retrieve the product_id inside the Views;
So, I started another way to manage this issue : I have created a shortcode that looks if all conditions are OK and then, the conditional output refers to this shortcode.