Skip Navigation

[Resolved] Need filter: send CRED emails only if …

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

Problem: I need to send a CRED email notification to a user, conditionally, based on a custom user field in that user's profile.

Solution: Add a generic field in your CRED form that includes the user's email address. Apply conditional logic around this generic field, and test if the user's custom field value is a match. If so, include the generic field. If not, do not include the generic field. In your CRED email notification settings, choose the generic field as the target of the email notification. If the generic field is not present because the conditional was not matched, the email will not be sent.

Relevant Documentation:
Documentation about generic fields in CRED:
https://toolset.com/documentation/user-guides/automated-email-notifications-with-cred/

Documentation about conditional output:
https://toolset.com/documentation/user-guides/conditional-html-output-in-views/

Documentation about getting user meta fields:
https://toolset.com/documentation/user-guides/displaying-wordpress-user-fields/

This support ticket is created 7 years, 7 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 4 replies, has 2 voices.

Last updated by peg 7 years, 7 months ago.

Assisted by: Christian Cox.

Author
Posts
#505993

peg

Hi there,
I have some custom post types that send emails to the users when they submit a cred form and similar. I need to make sure that those emails are only sent to the users if they are authorized by the user.
I have set up some user meta (checkbox) to let the user confirm the submission of emails.
Now the question: is there a filter that can check against the user meta before an email is sent?

Thanks,
Peg

#506010

Hi Peg,

There is not currently a way in the CRED mail notifications settings to access User meta information directly, but you can access any generic field that you add to the CRED form. I think we could use this feature to get the user's email.

First add a generic field to your CRED form that includes the User's email address. Once you have that displaying, add some conditional HTML logic to show the User's email address only if the user's meta checkbox is checked.

Then, in the email notifications section, you can select to send a notification to the generic email address field. If the field is not included in the form, the mail won't get sent to them. If it is included in the form, it gets sent successfully.

Do you think this approach will work for you?

Documentation about generic fields in CRED:
https://toolset.com/documentation/user-guides/automated-email-notifications-with-cred/

Documentation about conditional output:
https://toolset.com/documentation/user-guides/conditional-html-output-in-views/

Documentation about getting user meta fields:
https://toolset.com/documentation/user-guides/displaying-wordpress-user-fields/

Please let me know if you need additional guidance on this approach, and I'll be happy to take a look, though the day is almost ending for me and it may be Monday before I get a chance to respond.

#506014

peg

This is a great idea, Christian.
Let me try this out and report back to you.

Regarding the conditionals: I think you mean view conditionals like [wpv-conditional ... ] and not cred conditional logic, right?

#506015

That's correct - not CRED conditional logic (even though we're talking about a CRED form) but conditional HTML output. I'll look forward to your results!

#506376

peg

Hi Christian,
Your approach is really excellent. Works like a charm!
Thanks a lot!
I am closing this ticket.
Best,
Peg