Skip Navigation

[Resolved] How to create input from guests without making them users

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.

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Kolkata (GMT+05:30)

This topic contains 7 replies, has 2 voices.

Last updated by Minesh 1 year, 3 months ago.

Assisted by: Minesh.

Author
Posts
#2632861

Hi, can you give me some advice on the following.

I want guests that come on my website (travel site) submit an enquiry for a specific travel package.
There I would need to collect various information (Name, destination, preferences,timing, etc)

I have been playing around with the Access Control, create Custom Type for users but cannot find the right approach.
Tried it with User Forms and Post Forms ( which gives me CRED files I cannot open)
I can easily create users but the information I can see then ( probably from WordPress standard) is too limited.

The point is I don't want these guests to become users ( subscribers or otherwise) because they will be one time visitors generally.
Can I use Toolset to create this or do you advise to use a plug-in?
I would prefer Toolset because I can include fields etc.

I hope this description is not too confusing and that you can point me in the right direction
Thanks
Dirk

#2632879

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

What you should do it create a custom post type "Travel Inquires" and further create custom field group and add your required custom fields you want.

Please check the following Doc that shows how you can create custom post types and custom fields.
https://toolset.com/course/custom-types-in-wordpress/

if you would like to know for what package you got what inquiry, then you can create post relationship between the post type "Travel Inquires" and your travel package post type.
- https://toolset.com/lesson-placement/lesson-placements-1729031-1727273/

Then you should create a post form for your post type "Travel Inquires", please check the following doc:
- https://toolset.com/lesson-placement/lesson-placements-1621521-1612071/

Once you create that form you should display that form at your desired place:
- https://toolset.com/lesson-placement/lesson-placements-1621521-1612071/#displaying-toolset-forms

You can also set the permission for guest user so the form will be displayed for guest user:
- https://toolset.com/course-lesson/controlling-access-to-front-end-forms/
[You can grant the permission for the Guest role so that guest users can see the form on the frontend]

There are number of courses available, please check the following:
- https://toolset.com/course/

I hope all above information will help you to resolve your issue.

#2633139

Hi Dinesh,
I followed the steps.
Created new Post Type + Custom fields to capture the necessary info ( Name, Address, etc)
Create a Form
Create a Page where to fill in the form.
I can see the form and fill it out, and submit it.
But when I try to get date from the newly create Post type I see

CRED Auto Draft 9834517451092c343e3fe7eafdb25bc9

I have not activated Toolset Access, maybe I should do this ?
Thanks
Dirk

#2633529

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

No - I would like not know what you want to have as a post title.

What combination of your custom field values of your contact form you want to see as post title?

Can you please share what fields you created with your custom field slugs and share this information and I would be happy to help. Also, did you create post relationship between your post type?

#2633585
Form Offertes.png
Filled in Offertes.png
Dashboard  Offertes.png
Front end input form Offertes .png
Filed Group Offertes .png

Hi Minesh ,

I add the different screen shots on how I created the "Offertes" (which are inquiries) , set up the form , display the form and what the results are after input.

So :
I can display the input form on the front-end , register an input and afterwards fire the input.
The only inconvenience is that all inputs have as title a CRED draft xxxxxx format.
I would like to see as title the field "Familienaam"as I circled in the screenshot .

I have not created any relationship. I honestly do not know between what I should define the relationship

Hope this helps my explanation on where I am at .

Thanks
Dirk

#2633627

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

You should try to add the following code to "Custom Code" section offered by Toolset:
=> https://toolset.com/documentation/programmer-reference/adding-custom-code/using-toolset-to-add-custom-code/

You can add a new code snippet to "Custom Code" section and add the following code to that snippet after the following line in your code snippet:

toolset_snippet_security_check() or die( 'Direct access is not allowed' );

add_action('cred_save_data', 'func_build_post_title', 10, 2);
function func_build_post_title($post_id, $form_data) {

if ($form_data['id']==9999) {
$field = get_post_meta($post_id, 'wpcf-familienaam', true);
 
$post_title=$field;
$slug = sanitize_title($post_title);

wp_update_post(array('ID'=>$post_id, 'post_title'=>$post_title,'post_name' => $slug));

}

}

Where:
- Replace 9999 with your original form ID,
- Replace familienaam with your original custom field slug if required

More info:
=> https://toolset.com/documentation/programmer-reference/cred-api/#cred_save_data

Once you do that please make sure your code snippet is active and then try to create a new entry and see if you able to see the post title.

#2633737

Hi Minesh,
Perfect , thank you it works.

Small extra question because I'm not familiar with coding so much

If I would like in the post title 2 post fields would the syntax be as follows? or different

$field = get_post_meta($post_id, 'wpcf-offerte-familienaam', 'wpcf-offerte-voornaam', true);

Thanks
Dirk

#2633893

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

You can try to use the following modified code:

add_action('cred_save_data', 'func_build_post_title', 10, 2);
function func_build_post_title($post_id, $form_data) {
 
if ($form_data['id']==9999) {

$field_familienaam = get_post_meta($post_id, 'wpcf-offerte-familienaam', true);
$field_voornaam = get_post_meta($post_id, 'wpcf-offerte-voornaam', true);
  
$post_title = $field_familienaam." ".$field_voornaam;

$slug = sanitize_title($post_title);
 
wp_update_post(array('ID'=>$post_id, 'post_title'=>$post_title,'post_name' => $slug));
 
}
 
}

Where:
- Replace 9999 with your original form ID,

#2633913

Thank you very much for the accurate support
Rgds
Dirk