Skip Navigation

[Resolved] Custom Notification to users , certain criteria

This support ticket is created 5 years, 5 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
- 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 -
- 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 -

Supporter timezone: Europe/London (GMT+00:00)

This topic contains 3 replies, has 2 voices.

Last updated by Nigel 5 years, 5 months ago.

Assisted by: Nigel.

Author
Posts
#1317031

In User - I have a custom field called ‘District’



The field is a Select field with District 1, District 2 and so on.

I want to make Form notification only to Users that have E.g ‘District 1’ in the Custom field

.

Is this possible without custom code?

#1317105

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

Screenshot 2019-08-15 at 13.56.55.png

Hi Thomas

Yes, that should be possible.

Check the notifications section you can see in my screenshot.

The "When custom fields are modified" condition includes when the custom field goes from not-existing to having some value, i.e. when the post is first published.

So you can add the condition for your district custom field there to specify when the notifications should be sent.

#1317121

Thank you for reply.

Unfortunately, it did not help me, and I guess because I worded the question wrong.

Can we di one more try?

I want tol create a submit news form. But the notification when this form is submitted should only go to all the Userers that have already i.e. 'District 1' as a value in the select field in the Custom User field 'District'

Hope that make sense and that is still is possible to do?

#1317151

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

Sorry, I mis-read your question.

In that case, no, it's not possible to do this without writing some custom code, where you would use the Forms API to modify the recipients of the notification.

You would send a notification to some admin account on form submit.

You would then use the cred_notification_recipients filter to modify who the notification was sent to, in this case running a user query to get users who have the required custom user field value, and then updating the list of recipients to cc: or bcc: these users.

There is an example of using that filter here: https://toolset.com/documentation/programmer-reference/cred-api/#cred_notification_recipients

You can use the WordPress function get_users (https://developer.wordpress.org/reference/functions/get_users/) to retrieve the matching users. The available arguments are described here: https://developer.wordpress.org/reference/classes/wp_user_query/prepare_query/