Skip Navigation

[Resolved] Form with 7 day selection that links to next date matching selected day?

This support ticket is created 5 years, 9 months ago. 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.

Our next available supporter will start replying to tickets in about 0.84 hours from now. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

This topic contains 3 replies, has 2 voices.

Last updated by Christian Cox 5 years, 9 months ago.

Assisted by: Christian Cox.

Author
Posts
#958008

Tell us what you are trying to do?
Create a form that allows UserA to set a weekly schedule by day (Sun/Mon/Tue/Wed/Thu/Fri/Sat) and time. Present that weekly schedule to UserB as a date selector based the same day in the upcoming week (ex: Sunday = Sunday 7/29/18).

Is there any documentation that you are following?
CRED/forms documentation. Selecting Parent Posts when Using Forms to Create Child Items
(https://toolset.com/documentation/post-relationships/selecting-parent-posts-using-forms-create-child-items). Displaying Fields of Grandparents (https://toolset.com/documentation/post-relationships/how-to-display-related-posts-with-toolset/displaying-fields-of-grandparents).

Is there a similar example that we can see?
Unsure, was following model of Property, City, Country and hoping I can replicate by Day, Time.

What is the link to your site?
Local site only.

#958321

Hi, what you're describing sounds fairly custom, and I don't have a cut-and-paste solution for you. It sounds like you need to create one Form that allows User A to select a day and time, then you need to use those values together with the current date and time to calculate the next possible occurrence of that combination of day and time, on demand, when a different Form is visited by User B. There you need to predefine a custom date field with that value. I can offer some general advice, but this is outside the scope of support we provide here in the forums.

Here's how you set a custom date field's value in a Form. Notice that date fields use timestamp values:

[cred_field field='start-date' value='1532890285' class='form-control' output='bootstrap']

https://www.epochconverter.com

To access a value from a custom field in any post, you can use get_post_meta in PHP:

$day = get_post_meta(1234, 'wpcf-day', true);
$time = get_post_meta(1234, 'wpcf-time', true);

Toolset custom fields use the prefix 'wpcf-' in the database.
https://codex.wordpress.org/Function_Reference/get_post_meta

To calculate a timestamp, you need to understand PHP date manipulation. I recommend you check out the documentation here:
@php.net/manual/en/function.date.php
You need to write a script that creates a timestamp using the current date, the selected day, and the selected time.

If you have specific questions about problems you run into with Toolset APIs, I will be glad to take a look. If you need professional assistance creating this type of system, we have a portal available where you might be able to connect with a skilled independent developer who can help. https://toolset.com/contractors

#958343

Thank you Christian. This is a very helpful explanation and suggests I may able to query 3rd party booking/events plug entries as well, so long as I know what their prefix is in the database? I did find that Events Manager uses a format of "07/29/2018" for its event start date posts, while Toolset appears to drop in "July 29, 2018" into the database when I am just using the standard date field entry option.

Would Toolset's Date filters (https://toolset.com/documentation/user-guides/date-filters) be of any use here? I assume that's just for filtering a list of existing entries versus actually pulling from a specific user's post entry (as we're doing by going the PHP route)?

#958362

while Toolset appears to drop in "July 29, 2018" into the database when I am just using the standard date field entry option.
Toolset's custom field dates are stored as timestamps in the database, so I'm not sure where you're seeing "July 29, 2018". Can you show me a screenshot?

Would Toolset's Date filters (https://toolset.com/documentation/user-guides/date-filters) be of any use here?
These date filters are useful if your Users need the ability to search for results and filter by custom field dates or custom field date ranges. Based on what you have described to me so far, I don't see any need for Views yet.

This ticket is now closed. If you're a Toolset client and need related help, please open a new support ticket.