Skip Navigation

[Resolved] How can i make a contact form for visitors to contact our artists?

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
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9: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/Karachi (GMT+05:00)

This topic contains 10 replies, has 2 voices.

Last updated by Waqar 7 months, 1 week ago.

Assisted by: Waqar.

Author
Posts
#2690945

How can i make a spam safe contact form for visitors to contact our artists?

I tried to find this in the search section and in the lessons, but didn't find it.

#2691049

Hi,

Thank you for contacting us and I'd be happy to assist.

You can use Toolset Forms for this and we have a guide on using them at:
https://toolset.com/lesson-placement/lesson-placements-1621521-1612071/

Using Toolset Types, you'll first create a new custom post type for example "Contact Requests".

And after that, you'll add a new post form, to create a new post in this post type, whenever this contact form is submitted. This way all contact requests will be saved and you can also attach an email notification with this form to notify the admin or user(s), about a new submission.

And for spam protection, Toolset Forms also support the ' Google reCAPTCHA', as explained here:
https://toolset.com/course-lesson/protecting-forms-from-spam/

I hope this helps and please let me know if you need further assistance.

regards,
Waqar

#2691246

Hi,
i managed to setup the contact form and post type. But i cant find how to connect the post to the specific user/artist.
Also can't find how to select that artist to receive the e-mail. (I'm also trying to find out which message content field i should use, but i might find that one out myself)

Is it the idea that the artist also sees the post that is directed to him and can reply to that from the website? Or should he only receive the email message and reply to that?

Thanks in advance!

#2691496

Thanks for writing back.

You can add the following custom fields to this post type "Contact Requests":

1. Contact Request Source:

This can be a single-line type field, that will store the name/title of the artist or artwork post from which this contact request originated from.

Because the form to create a "Contact Requests" will be placed on a single artist post or a single artwork post, the value of this field can be automatically populated by adding the '[wpv-post-title]' shortcode in that field's default value setting in the form.
( ref: https://toolset.com/documentation/programmer-reference/views/views-shortcodes/#wpv-post-title )

2. Contact Request Artist Email:

This will be an email-type field, and its default value in the form can be automatically populated through the shortcode '[wpv-post-author format="meta" meta="user_email"]' in the default value setting in the form.
( ref: https://toolset.com/documentation/programmer-reference/views/views-shortcodes/#wpv-post-author )

As a result, the email of the post author of the current artist or the current artwork post will be filled in this email field. And you can then use that field's value in the form notification too.

#2691782

Hi, After seeking and trying for a few hours i feel embarrassed that it still doesn't work.

Well, i did what you said, and that worked, but i can't select the e-mail address of the addressed artists in the e-mail notification field. I can only select the senders' e-mail address, and i don't want the e-mail to go there. 🙁 I also tried the [wpv-post-author format="meta" meta="user_email"] shortcode in the "Send notification to a WordPress user: " field.

Also, the sender's e-mail address should be used for sending the message, so that the artists can simply reply to the e-mail. Is that possible? I can imagine though, that this might interrupt e-mail traffic because then the website is sending e-mails with different senders domains.

Also i'm trying to make the created posts available for only the artist that it is addressed to, or is that not the idea of this? It would be great it the artist can few his/her messages on the website and simply click on reply.

What's the correct workflow for this messaging?

Thanks again..

#2692056

> Well, i did what you said, and that worked, but i can't select the e-mail address of the addressed artists in the e-mail notification field. I can only select the senders' e-mail address, and i don't want the e-mail to go there. 🙁 I also tried the [wpv-post-author format="meta" meta="user_email"] shortcode in the "Send notification to a WordPress user: " field.

- I see that with the 'Contact Verzoeken' post type there is just one email type custom field ( 'e-mail adres' ) registered for the sender's email.

For the artist's email, there is no email type custom field added, instead, a generic email field is being used. The value of the generic fields is not saved/recorded with the created post and it is also not available in the form notification's settings.

You can add another email-type custom field in the custom field group 'Post Field Group for contactform' and use that in the form in place of the generic email field. After this change you'll be able to use that field in the form notification's 'To' settings.

> Also, the sender's e-mail address should be used for sending the message, so that the artists can simply reply to the e-mail. Is that possible? I can imagine though, that this might interrupt e-mail traffic because then the website is sending e-mails with different senders domains.

- In the form's email notification settings there is no built-in option to set a dynamic 'From' email address. That is due to the reason that you mentioned, that sending out emails from different domains, affects email deliverability.

Alternatively, you can use the 'cred_mail_header' hook ( ref: https://toolset.com/documentation/programmer-reference/cred-api/#cred_mail_header ), to dynamically set the 'sender's email' into the 'Reply-To' header, so that when the received email is replied to, it will automatically use the sender's email address for the 'To' address.

You'll find an example code snippet for a similar usage in the following forum thread:
https://toolset.com/forums/topic/emails-from-a-toolset-form-needs-to-reply-to-the-person-who-submitted-it/

> Also i'm trying to make the created posts available for only the artist that it is addressed to, or is that not the idea of this? It would be great it the artist can few his/her messages on the website and simply click on reply.

- Just as you'll be storing the 'Contact Request Artist Email' with each created 'Contact Verzoeken' post you can add a numeric custom field 'Contact Request Artist ID' and store the addressed artist's user ID too.
( for the default value in the form, you'll use the shortcode [wpv-post-author format="meta" meta="ID"] )

Storing the addressed artist's user ID with each contact request will allow you to:

a). Use the conditional block to show the content of the message only to the addressed artist on the single 'Contact Verzoeken' post pages,
( i.e. show the content only if the 'Contact Request Artist ID' is the same as the current user's ID )

and

b). To show the list of all messages sent to a particular artist, through a post view with a custom field filter based on the field 'Contact Request Artist ID'.
( i.e. show all 'Contact Verzoeken' posts where 'Contact Request Artist ID' is the same as the current user's ID )

#2692320

Thank You,
I added the snippet in the code snippets plugin (Please remember i do not know anything about php, that's why i use toolset)

//Customise CRED notifications
function customise_cred_notifications( $headers, $formid, $postid, $notification_name, $notification_number ) {
if ($formid==3413 && $notification_name=='Contactverzoek') {
$myheaders = array( 'Reply-To: '.$_REQUEST["form-email"] );
return array_merge($headers, $myheaders);
}
return $headers;
}
add_filter('cred_mail_header', 'customise_cred_notifications', 10, 5);

But unfortunately it doesn't work and now the mails ain't sending anymore. (So it dit sòmething 🙂 )

#2692322

oh sorry, it seems that the e-mails dó send, but with some delay. Nothing changed in the header though...

#2692492

I'll recommend the following two adjustments in the code snippet:

1). The target notification name is 'Nieuw bericht via Kunstwerken.art' but your code is using the form's name 'Contactverzoek'.

2). The target custom field's slug for the person filling the content request is 'e-mail-adres-contactformulier', but the code is using the slug 'form-email'.

Here is the updated code with both these changes:


//Customise CRED notifications
function customise_cred_notifications( $headers, $formid, $postid, $notification_name, $notification_number ) {
    if ($formid==3413 && $notification_name=='Nieuw bericht via Kunstwerken.art') {
        $myheaders = array( 'Reply-To: '.$_REQUEST["wpcf-e-mail-adres-contactformulier"] );
        return array_merge($headers, $myheaders);
    }
    return $headers;
}
add_filter('cred_mail_header', 'customise_cred_notifications', 10, 5);

#2692618
Schermafbeelding 2024-04-16 104127.png

Thank you very much, it's all working now!
The only thing that is left, is that i want to hide the prefilled fields. I tried it with css, but didn't work.
See image

#2692626

Thanks for the update and glad that it is working.

To hide the second last row of this particular form, you can use the following custom CSS code:


form[id^=cred_form_3413_] > .container-fluid div.row:nth-last-child(2) {
    display:none;
}