Skip Navigation

[Resolved] A form for visitor to send email to the post's author

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 7.04 hours from now. Thank you for your understanding.

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 20 replies, has 2 voices.

Last updated by Tien Nguyen 1 year, 11 months ago.

Assisted by: Minesh.

Author
Posts
#2493277

*Tell us what you are trying to do?

I have an advertising post of room. I want to create a form for visitors to email to the post's author and webiste's admin. The email will be attached with some field in his post. Can I do it with Toolset?

*Is there any documentation that you are following?

*Is there a similar example that we can see?

*What is the link to your site?

#2493387

Minesh
Supporter

Languages: English (English )

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

Hello. Thank you for contacting the Toolset support.

Toolset offers Email notification feature that you can use it to send emails. Here is the Doc:
=> https://toolset.com/course-lesson/send-notifications-when-someone-submits-the-form/

Can you please check and see if that help you to resolve your issue. If you require further assistance please feel free to get in touch with me with problem URL where you added the form and with details about what field you want to use and holds the email.

*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.

I have set the next reply to private which means only you and I have access to it.

#2497145
screencapture-giaodichkynghi-wp-admin-post-php-2022-11-16-09_57_51.jpg

Thank for your information.

Now I have a post form for a visitor send email to post author with his information including name, phone, email, ...

In back-end, I've created some fields from Generic fields, I mean these are not from custom fields I created before. How can I add them to email body sending to post author.

Best regards.

#2497387

Minesh
Supporter

Languages: English (English )

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

Here is a detailed Doc about how you can use custom placeholders and add those placeholders to your email subject/body.

More info:
- https://toolset.com/documentation/programmer-reference/forms/how-to-use-custom-placeholders-in-cred-notifications/

#2497657

Excuse me, I'm not a coder and english is not my native language, so it's quite hard for me to understand your information.

For now, I cannot create a form successful as my wish. In my understanding, if a visitor complete a form in a post, Toolset will create a new post, won't it?

In my case, I'm creating a post of advertising a timeshare for sales or for rent. I want the post author will receive an email with information of his timeshare like room, sleeps, nights, week,... and privacy information of the visitor who complete the form like name, phone, email.

I have an idea. Can I create a new Post Type named Contact and attach its form into the post of timeshare for sales? By this way, I can manage the information of all visitor who complete the contact form. Is it logical?

#2498027

Minesh
Supporter

Languages: English (English )

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

For now, I cannot create a form successful as my wish. In my understanding, if a visitor complete a form in a post, Toolset will create a new post, won't it?
==>
Yes, thats correct.

I have an idea. Can I create a new Post Type named Contact and attach its form into the post of timeshare for sales? By this way, I can manage the information of all visitor who complete the contact form. Is it logical?
=>
Yes, its logical. You can create one-to-many relationship between your current post type (one) and Contact (many) post type.

If you have any issue and need a test platform, here is a sandbox site you can use:
- hidden link

Please let me know if your require further assistance.

#2498329

Hi Minesh,

I created a form of repeatable field group of the custom post named Timeshare for Sales and insert it into template of Timeshare for Sales. But the form cannot send email to the post author when it is submitted, instead, it send email to admin. Please help me.

Second, can I remove or hide the field to select the parent post? Is there a way to the form choose the parent post automatically - the post where the form is submitted? This is important for me. I don't want a guest see long list not relevant to the post they want. By the way, if I check "Get only options by the current author" in Filtering by author, there is no result show up in front-end.

Best regards.

#2498835

Minesh
Supporter

Languages: English (English )

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

I'll have to review your current setup and form setup.

Can you please send me problem URL where you added the form as well as admin access details and tell me to what email you want to send the email.

*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.

I have set the next reply to private which means only you and I have access to it.

#2498933

Minesh
Supporter

Languages: English (English )

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

Thank you for sharing access details.

I'm not sure but I'm seeing the fatal error when I submit the form. To know that whats the error I will require FTP access details.

Can you please send me FTP access details.

I have set the next reply to private which means only you and I have access to it.

#2499015

Minesh
Supporter

Languages: English (English )

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

I've removed the parent field from your form as its not required the logic is the parent would the automatically where the form is available to submit.

I've added the following generic fields to your form just before the submit button:
=> hidden link

[cred_generic_field type='hidden' field='@thong-tin-mua-lai.parent']
{
"default":"[wpv-post-id]"
}
[/cred_generic_field]
	
	[cred_generic_field type='hidden' field='parent-post-author-id']
{
"default":"[wpv-post-author format='meta' meta='ID']",
"generic_type":"user_id",
"persist":1
}
[/cred_generic_field]

I've added the following code to "Custom code" section offered by Toolset that will help us to set the parent ID for the post you create using the form:
=> hidden link

add_action('cred_save_data','func_custom_set_parent',15,2);
function func_custom_set_parent($post_id,$form_data) {
    if ($form_data['id']==883) {
         toolset_connect_posts('thong-tin-mua-lai',$_POST['@thong-tin-mua-lai_parent'], $post_id);
    }
}

And with your notification I've set the option "Send notification to a WordPress user with an ID coming from a generic field in the form" and selected the option "parent-post-author-id'" which is set by the generic field which has the author ID.

Can you please confirm now it works as expected.

#2500253
2211202143.jpg

Hi Minesh,

I've seen your coding. It works! Thank you so much.

And I have 3 issues need your helps.

1. Please guide me to change some elements like the photo I attach.
2. I've cloned the post form to another and renamed it to "Liên hệ thuê lại" (Contact to rent), then I inserted it to "Thuê lại" (For rent) post type. It still works well. But I see in Custom Code, you mentioned "if ($form_data['id']==883)". My question is that, does it work for Contact to rent? Liên hệ thuê lại (ID: 1352)
3. I cannot see the form from mobile device, and from Firefox or Edge.

Hope you answer soon.

Best regards.

#2500669

Minesh
Supporter

Languages: English (English )

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

1. Please guide me to change some elements like the photo I attach.
==>
I've changed it, you need to add placeholder attribute to your [cred-field] shortcode and you can comment out the label tag, for example:

<!-- <label for="%%FORM_ID%%_muc-gia">[cred_i18n name='muc-gia-label']Mức giá[/cred_i18n]</label>-->
		[cred_field field='muc-gia' force_type='field' class='form-control' output='bootstrap' placeholder="Mức giá"]

2. I've cloned the post form to another and renamed it to "Liên hệ thuê lại" (Contact to rent), then I inserted it to "Thuê lại" (For rent) post type. It still works well. But I see in Custom Code, you mentioned "if ($form_data['id']==883)". My question is that, does it work for Contact to rent? Liên hệ thuê lại (ID: 1352)
==>
Yes, if you want to apply the same code that is added and if its using the same post relationship then you will have to use the following if condition:

  if ($form_data['id']==883 or $form_data['id']==1352) {

3. I cannot see the form from mobile device, and from Firefox or Edge.
==>
Do you mean you do not see the form when you are not loggedin? If yes, you need to set the access permission with guest user. Navigate to:
=> Toolset => Access Control => Toolset Forms tab => Post Forms Frontend Access section and your desired role who can access the form and save the settings.

#2503011

Hi Minesh,

I see in custom code:

add_action('cred_save_data','func_custom_set_parent',15,2);
function func_custom_set_parent($post_id,$form_data) {
if ($form_data['id']==883) {
toolset_connect_posts('thong-tin-mua-lai',$_POST['@thong-tin-mua-lai_parent'], $post_id);
}

I have 2 repeatable groups is thong-tin-mua-lai (contact for sales) and thong-tin-thue-lai (contact for rent). Form id 883 is for thong-tin-mua-lai, and 1352 is for thong-tin-thue-lai. Please help me know the code line.

Best regards.

#2503033

Minesh
Supporter

Languages: English (English )

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

To the form ID 1352 - have you added the generic fields that we have added to your another form?
- https://toolset.com/forums/topic/a-form-for-visitor-to-send-email-to-the-posts-author/#post-2499015

#2503047

I dont't quite get your question. I just cloned the form you made Liên hệ mua lại (id 883) to Liên hệ mua lại (id 1352). Then in form editor of the form id 1352, I replaced lines "thong-tin-mua-lai" by "thong-tin-thue-lai". I see it works well. I've not fix the code in setting/custom code yet.