Skip Navigation

[Resolved] Send CRED notification to email from parent post custom field

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.

This topic contains 15 replies, has 3 voices.

Last updated by thomasD-2 6 years, 6 months ago.

Assigned support staff: Ana.

Author
Posts
#245064

I have pretty much the same problem as described in this topic:
https://toolset.com/forums/topic/cred-notification-2/
But the solution described there doesn't work.

In a parent post there is a custom field with an email address. By clicking on a link the user get to a CRED form that creates a child post and sends a notification by email. Allt his works fine so far. But now I want the notification email to be sent dynamically to the email adress specified in the parent post. I followed the steps in the metioned topic:
1. I created a view that extracts specifically the email address from the parent post. The view works, I can include the view in the cred form, and it shows the email address in the text (but with a blank at the first and last position)
2. I created a generic field for email address in the CRED form. It shows up in the form.
3. I added the view as the default value to the generic field -> and then the generic field does not show up anymore i the CRED form.

This is my code for the generaic field:

 
[cred_generic_field field="veranstvmail" type="email" class="" urlparam=""]
{
"required":0,
"validate_format":0,
"persist":0,
"default":"[wpv-view name="Veranstalter-Emailadresse"]"
}
[/cred_generic_field]

Are there any mistakes in the code? What else could be wrong? By the way: I'm using the latest versions of CRED (1.3.2) and the other plugins.

Why is this so complicated? And why doesn't exist a simple shortcode like [cred-post-parent get='title'] also for the other custom fields of the parent post?

#245258

You should set the "persist" argument to "1". Like this:

[cred_generic_field field="veranstvmail" type="email" class="" urlparam=""]
{
"required":0,
"validate_format":0,
"persist":1,
"default":"[wpv-view name="Veranstalter-Emailadresse"]"
}
[/cred_generic_field]

Please let me know if you are satisfied with my answer and if I can help you with any other related question.

#245489

Thx for your assistance. However the code doesn't work either. The Generic Field doesn't show up at all in the output page when the wpv-view is inluded as the default value. When I delete the wpv-view shortcode or type any other default vaule, the generic field is shown.

Any other idea how I could get the email adress into the generic field?

#245889

What's the format you are using for the View's output? It should be like this:

{"value":"Value 123","label":"Label 123"},
{"value":"Value 456","label":"Label 456"}

Please let me know if you are satisfied with my answer and if I can help you with any other related question.

#246207

Sorry, I don't understand your reply. Which "format for the view's output" do you mean?
I have defined a view that has the email adress of the respective parent post as output. It works when I test the view shortcode outside of an generic field. When I pit it in an generic field as shown in the code above, there is no output at all.

#246869

Ana
Supporter

Dear Thomas,

I need to request temporary access (wp-admin and FTP) to your site – preferably to a test site where the problem has been replicated if possible – in order to be of better help. You will find the needed fields for this below the comment area when you log in to leave your next reply. The information you will enter is private which means only you and I can see and have access to it.

Thanks,
Ana

#247100

Sorry, I dont understand. Where shall I provide the credentials for the access to my WP installation? I can see only this Reply field, and this doesn't seem to be private.

#247101

Well, it looks as if this reply field is indeed just a private message? How can I see whether it's private or not?

#247144

Ana
Supporter

Hi Thomas,

my mistake sorry hadn't enabled the private details box.
Now I have. It will display next to the this reply field.

Thanks,
Ana

#247156

Okay, this looks better now. Here we go.

Some hints:
the view is "veranstalter-emailadresse"
the CRED form is "anmeldung test" (I have replicated this as a test page, so you can do tests)
the relevant generic field is the last one before the submit button
the URL of the test page with the CRED form included is: [domain] /test-registration-form-wp-types/?parent_veranstaltung_id=31524

The final goal of all this is to channel the email adress invisibly through the form and then send the notification email to this email address.

Thank you for your assistance.

#247528

Ana
Supporter
Screen Shot 2014-09-29 at 16.35.43.png

Dear Thomas,

thanks for the detailed description and setting the test CRED form.

In order of an email field be available to use in the notifications he needs to have the parameter persist set to 1 this will make that field be saved to the database and this way when the notification is sent will be available.

I've set the cred generic field to be saved to the database in your test form and now it is available to the notifications settings.

[cred_generic_field field="veranstalter-amailadresse" type="email" class="" urlparam=""]
{
"required":0,
"validate_format":0,
"persist":1,
"default":"[wpv-view name="Veranstalter-Emailadresse"]"
}
[/cred_generic_field]

Please let me know if you are satisfied with my answer and if I can help you with any other questions you might have.

Regards,
Ana

#247796

Thx for your support, Ana. Indeed this works now, the email address is available in the notification settings. But now I'm facing the next problem: the email is not send out. If the field "veranstalter-emailadresse" is specified as To-address, no notification is sent at all. If it is the cc-address, emails are send ohne to the other defined To-adresses, but not to the email address specified in the field.
I assume that the reason is the fact that the email address is surrounded by 2 blanks at the front and at the end (even though the value of the originating field doesn't contain these blanks.
Any solution for this?

Moreover I'm wondering why the generic field with the email address as default does not show up in the form.Usually I would expect that the generic field is visible and I have to hide it via CSS. It's not a problem in this case, but it might be relevant for other use cases I have in mind.

#247838

Ana
Supporter

Dear Thomas,

about the blank spaces you can just edit the View and in the Layout output remove the blank spaces.
However I'm looking into a different issue that may be the cause of the notification not being sent.

Although the types shortcode that is used in the View to render the email as the raw attribute set. The email is being added in the CRED form with the a markup

<a href="mailto:the_email_field@some_domain.com">the_email_field@some_domain.com</a>

The same happens if an email is directly added to the CRED form.
I'm currently talking with the CRED developer and will post here when I have more news about this.

Thanks,
Ana

#248945

I have regognized that somebody has worked on my website, and the problem seems mostly solved now:
- the generic field shows up in the form (and then can be hidden via CSS)
- the notification email is sent to the email address specified in the view.

That's fine so far. The problem is that I can send only one email. I would like to send two emails - one to the email address as provided by the user in the registration form, and another one to the admin of the course as specified in the parent post. How is that possible?

#249294

Ana
Supporter

you can add another notification and specify the different email to be sent to.

This way the same CRED from will have two email notifications assigned, one to the email address as provided by the user in the registration form and the second notification to the admin of the course as specified in the parent post.

CRED allows you to create as many notifications as you need, so that different email can be sent.

Please let me know if you are satisfied with my answer and if I can help you with any other related question.