Tell us what you are trying to do? We need to create a series of events with a booking form for each event that allow the possibility to have a maximum number of people and close the booking until that number is reached.
The user data shall be stored somewhere to be used and exported by our client.
Any help or tutorial or similar project already done?
I'm not aware of a reference site available that will allow you to do exactly this. One ticket isn't sufficient to address everything here, so I will offer some general principles you can investigate:
- It sounds like you need an Event custom post type, so you should explore how to create an Event custom post type that captures all the necessary event information.
- It sounds like you need allow Users to associate themselves with any Event, so you should explore how to associate Users with a custom post type using CRED. One way to do this is to use a repeating custom field that stores the User ID of each User associated with the Event.
- It sounds like you need to stop Users associating themselves with an Event based on the number of other Users associated with the Event, so you should explore how to use the cred_form_validate API to validate form submissions based User associations. You might also want to check this ticket for information about counting the number of repeating fields: https://toolset.com/forums/topic/how-to-count-repeated-field/#post-412707
- It sounds like you need to be able to export data from the system. Toolset isn't designed to export data, but Views is designed to display formatted lists of data. So if copy+pasting from a View is sufficient, this might be feasible. Otherwise, you'll need to look for other 3rd-party tools to generate export files.
If you have specific questions about any of these ideas, feel free to open a separate ticket for each question so we can discuss in greater detail.
Hi Christian,
glad to hear from you.
What I thought so to make things simple is to work in this way:
1. create a custom post type named CONTACTS made out of NAME, SURNAME, EMAIL and a PRIVACY checkbox
2. create a CRED form to populate that custom post type
3. exporting the data stored in the CONTACTS post type with a 3rd party plugin
The only thing we need is to create the counter that calculates how many places are left to be booked and tell the CRED form to display a message similar to "no places left" when the maximum number of booking is reached (and disallow the form to be filled in or tell the form to display="none".
If you could help us to create that counter functionality for the rest we think we don't need additional support.
Thanks in advance.
Franco
I wasn't clear from your description - are you planning to associate Contacts with Events, or are you simply storing a count of the number of signups?
1. You must associate Contacts with Events to be able to determine later who is signed up, send CRED notifications to those Users, let Contacts see which Events they have signed up for, etc.
2. You can simply count number of signups instead of associating Contacts if you don't need that information later.
If it's #1, how are you planning to associate Contacts with Events, in technical terms?
Hi Christian,
the best would be associating an event with their booking subscriptions, but since I need this form for an event that occurs tomorrow, I need to get as simple as possible.
What I did until now you can see in this page:
hidden link
The forms stores correctly and sends the notification to the user.
What it misses is: counting the number of submissions, and the user in the notification e-mail gets the wrong "event title" (I placed in the e-mail notification text the %%post-title%% tag, but instead to write the parent post where the form is placed, it displays the CRED form code (something like : CRED Auto Draft 934j3hd7wjdfre0fe8wj).
How can I get those 2 things working?
Thanks Franco
Hi Christian, we activated the CRED form in a post and it works except that the user and our clients do not receive any notification upon completion of the form except if I fill in the form with a gmail account and in that case I receive the notification. What could be the reason?
Franco
What it misses is: counting the number of submissions
1. Create a "number" custom field called "submission-count" on the Event post type. Make the default value 0.
2. Create a "number" custom field called "event-id" on the Submission post type.
3. Use the wpv-post-id shortcode to specify the value of this event-id field in the CRED form. This should place the current Event id in the event-id field, so you can access that information later for each submission. You need this because there is no other relationship that will allow you to send the event title in the email notification.
4. Use the cred_save_data hook to programmatically increment the submission-count field number in the correct Event when the form is submitted successfully. Something like this:
add_action('cred_save_data', 'cred_increment_submissions_action',10,2);
function cred_increment_submissions_action($post_id, $form_data)
{
$forms = array( 123 );
// if a specific form
if (in_array($form_data['id'], $forms))
{
$eventid = $_POST['wpcf-event-id'];
$count = get_post_meta( $eventid, 'wpcf-submission-count', true );
update_post_meta( $eventid, 'wpcf-submission-count', $count+1 );
}
}
the user in the notification e-mail gets the wrong "event title"
5. If you add the event-id custom field as described above, then you can use that field value in a wpv-post-title shortcode like this to display the Event's title:
[wpv-post-title id="[wpv-post-field name='wpcf-event-id']"]