Skip Navigation

[Resolved] Contact form to post author

This thread is resolved. Here is a description of the problem and solution.

Problem: I have a CRED form that creates new posts. When the form is submitted I would like to send a notification to the author of the custom post where the form is displayed, not the author of the post being created by CRED.

Solution: Add a hidden generic field to the CRED form and set the value to be the author's email address:

<div style="display:none;">
[cred_generic_field field='currentpostauthor' type='email' class='' urlparam='']
{
"required":0,
"validate_format":0,
"default":"[wpv-post-author format='meta' meta='user_email']",
"persist":1
}
[/cred_generic_field]
</div>

Then you can access the currentpostauthor field in the email notification destination editor.

100% of people find this useful.

This support ticket is created 6 years, 8 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.

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 11 replies, has 3 voices.

Last updated by tinoU 6 years, 7 months ago.

Assisted by: Christian Cox.

Author
Posts
#735487

I've built a site for summer rentals of accomodations. (I'm using Toolset and beaver Builder.) It's a portal where people sign up to add their objects in a cred form. No bookings will be on the site. The guests will take contact via a contact form on the single CPT object page. I tried different ways to add the post author as the reciever of the email, but without success.

I tried to add the field connection [wpv-post-author format="meta" meta="user_email"] to the "send to" field in a Beaver Builder Contact Form Module (as well as UABB:s') and I also created a CRED form with a CPT named Contacts, but the Send notification to Author option doesn't seem to work, and neither any of the other options.

I searched your forum but I only get confused. I found something about a filter hook. Is that a way to go? Or do I need to try this with Gravity Forms or similar plugins?

#737276

Hi, let's try the following troubleshooting steps first:
- Are you using any SMTP plugins? CRED's email notification functionality is overridden by most SMTP plugins in a way that Toolset cannot control.
- Use the "test email" button to send a test email to your own address. Does the email arrive as expected?
- Temporarily deactivate all other plugins except Types, Views, CRED, and Beaver Builder. Activate a default theme like Twenty Seventeen. Test again. If the problem was resolved, reactivate your theme and other plugins one by one until the conflict is revealed.
- Can you take a screenshot of the CRED Form editor screen, so I can see the Email notification configurations?

#741534
screencapture-hyrboendegotland-se-wp-admin-post-php-2018-04-26-12_40_07.jpg

Hi, Christian,

now I tried almost everything but nothing works. Yes, I installed a SMTP plugin. On another older Toolset site I built I needed that to get the cred email notifications to work. When I send test mail from the cred form to my private email on this new site, the plugin has to be activated to recieve the test message. On my job email it works both with and without the SMTP plugin activated.

I inactivated most of the plugins, erased all other content in the CPT single content template, even switched off BB and UABB, and activated twenty seventeen, but still without success.

One strange thing I noticed when the BB template was activated was that the shortcode [wpv-post-author format="meta" meta="user_email"] displayed the admin email address instead of the authors' when it was put AFTER the cred shortcode, [cred_form form="kontakt"]. Put BEFORE, it showed the authors', as intended. But without BB in the content template it showed everything as i should. Though, the email notification didn't work in any of the ways.

#744462

Okay and you're checking your spam folder on your private email address to be sure the test message isn't getting caught? It doesn't make sense the CRED would be able to send a message to one address but not another when SMTP is deactivated, but there could be something else going on. If you'd like, I can log in, create a clone of your site, and install it locally where I can test all the notifications with various addresses.

#745590

I'm testing a clone with the same theme and plugins active (except SMTP) and the emails are going through as expected to all the test email addresses. Can you share the email address that is not working for you? Private reply fields activated.

#762037

There's no option in the wp-admin notification to send an email to the author of the post where the form is shown, but there is an option to send a notification to an email in a generic field. So create a generic email field in the CRED form and populate it with the email address of the current post's author. Wrap it in a hidden div so it's not visible, and add the "persist" parameter like this:

<div style="display:none;">
[cred_generic_field field='currentpostauthor' type='email' class='' urlparam='']
{
"required":0,
"validate_format":0,
"default":"[wpv-post-author format='meta' meta='user_email']",
"persist":1
}
[/cred_generic_field]
</div>

Then you should be able to find the generic field "currentpostauthor" in the email notification options. If not, submit the form at least once and click the "refresh" button next to the destination select field.

#766992

Thanks Christian,

it works like a charm. Even my private email address works without smtp now. Strange.

Only downside with this method is all the Contact posts being created on your site. But I think we can live with that.

I suspect the way to add other data from the current post in the email subject line and mail body is the same. I tried it for current post author name and current post title and it seems to work. Am I right?

#768769
wrong.jpg
right.jpg

When loading the original Template for the current post the problem described in the last part of comment above (#741534) persists. I want the contact data for the landlord after/below the cred contact form. The user meta fields shows the right data but not the post author and post author email.

Hyresvärd: [wpv-post-author]
E-post: [wpv-post-author format="meta" meta="user_email"]

[wpv-conditional if="('[types usermeta='telefon'][/types]' ne '')"]Telefon: [types usermeta='telefon' user_is_author='true'][/types][/wpv-conditional]
[wpv-conditional if="('[types usermeta='mobil'][/types]' ne '')"]Mobil: [types usermeta='mobil' user_is_author='true'][/types][/wpv-conditional]

[wpv-conditional if="('[types usermeta='webbplats'][/types]' ne '')"]Webbplats: [types usermeta='webbplats' user_is_author='true'][/types][/wpv-conditional]

#771217

I suspect the way to add other data from the current post in the email subject line and mail body is the same. I tried it for current post author name and current post title and it seems to work. Am I right?
This approach works, or you could collect just the post ID. You can then use that value in any Types or Views shortcode to specify the post "id" attribute.

The user meta fields shows the right data but not the post author and post author email.
Please add the current page's post ID reference:
Hyresvärd: [wpv-post-author id="$current_page"]
E-post: [wpv-post-author format="meta" meta="user_email" id="$current_page"]
If this does not resolve the problem, I may need to take a closer look at how you have your BB templates and designs organized.

#786506

Works fine. Many thanks.

I'm having email notification problems with the user registration forms on the same site, so could you please keep your copy of the site and I will write another ticket for that issue.

#786541

Of course, I will hold on to the clone files for a while.

#1379159

Great it worked for me